-
July 9th, 2011, 05:11 AM
#1
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
Sukumar
-
July 9th, 2011, 06:19 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|