how many places refer to an object? can this be resolved?

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

ok so lets say i have a string that got passed into a method by ref but i
want to see how many other places that string is refered to is this
possible?
 
The fact that it was passed by-ref really doesn't matter, since strings are
always referenced implicitly. As for finding the graph of references you'd
have to use some of the profiling and possibly hosting APIs. That information
is simply not available from within the managed environment.
 
Let me clarify that a bit, reference passed strings do update the parameter
when they are returned, so there is some difference. The same with an out
classified string. I'll try and put together some code to clarify this a bit
better.

The information on finding the reference graph remains the same though.
 
Justin Rogers said:
Let me clarify that a bit, reference passed strings do update the parameter
when they are returned, so there is some difference. The same with an out
classified string. I'll try and put together some code to clarify this a bit
better.

Hopefully the following gives enough examples to make it clear:
http://www.pobox.com/~skeet/csharp/parameters.html

In this context, string is just a reference type like any other, and it
happens to be immutable.
 
Back
Top