Possible Duplicate:
Track all object references in C#
Strings are reference types. They have two parts; an object and a reference to object. For example;
string str1 = "Soner";
string str2 = str1;
str1 and str2 are references to same object, "Soner" is an object. Is there any way to find all references point to the same object? In this case, I try to find str1 and str2 just using "Soner" object?
Of course, I didn’t know also how to access to string object without any reference to it. I want to know if there is a way.
There isn’t any built in way to get all the refercences to an object at runtime within your CLR process. The GC does not give any information about object references.
Everything you could do is building custom “tracker” that keeps references to the objects after they’ve been added explicitly. Jon Skeet describes the basic idea here.