CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2008

    Reference vs Value type in C#

    Hi All
    I was developing C++/Cli library to use C++ third party library in my C# application.I wrote a method to retrive the collection of datasets from
    CLI library to C#.

    The method exposed from CLI library is void Query(List<Dictionary<int ,String^>^>^ %data);
    here i am using reference type in List. is it good to use reference types than value types in List?
    since it is a reference type the memory will be handled by gc. Does it affects my list when i am reading
    it in C# application. When GC will free the memory in this case?

    Thanks& Regards

  2. #2
    Join Date
    Jan 2010

    Re: Reference vs Value type in C#

    The GC will only free the memory when there are no more references to the objects involved - you don't need to worry about the GC. You only need to be aware of the differences between reference and value types, especially if you need to create a deep copy of the list for some reason.

    I recently wrote an explanation of ref & val types in a different thread, so if you're interested, check it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)