Hi Manikkoth,
Scott is right, there are very few instances where setting a reference to
null actually makes a difference. See the blog post at:
http://blogs.msdn.com/clyon/archive/2004/12/01/273144.aspx for more
information.
Hope that helps
-Chris
--------------------|
| I'm not sure that anyone is recommending that you explicitly set your
object
| references to null. Everything I've seen and read in my experience with
| .NET (since early betas) suggest that the only reason to explicitly set
your
| object references to null ("Nothing" in VB.NET) is when you want to let
the
| GC know that you are done with an object BEFORE the object reference
would
| NORMALLY go out of scope.
|
| If you had an object reference that was taking up precious system
resources
| and you were done using it, but the procedure still had a lot of work to
do,
| you could "potentially* get the object cleaned up sooner than normal by
| destroying the reference yourself prior to the end of the procedure.
|
| Under normal circumstances, you do not need to worry about explicitly
| destroying your object references.
|
|
[quoted text, click to view] | "Manikkoth" <Manikkoth@discussions.microsoft.com> wrote in message
| news:37EB95D4-737F-4246-AC29-527B0DA845BE@microsoft.com...
| > Hello,
| > Why is it recommended to set the strong reference to null once the use
is
| > over? Will the garbage collector be able to collect all my weak
reference
| > objects, if I set it to a strong reference again and again without
setting
| > the strong reference to null in between?
| >
| > somewhat like this
| > StrongReferenceXYZ=weak1;
| > StrongReferenceXYZ=weak2;
| > StrongReferenceXYZ=weak3;
| >
| > Do I need to set StrongReferenceXYZ=null in between?
| >
|
|
|