This is a general .NET question, but I provided C# code.
If I have an object that implements IDisposable and I call the .Dispose method, should I also set the object to null? I know about the "using" keyword, so no need to explain it or it's benefits.
Ex:
Should I do this...
...or...
...or...
Thanks in advance.
CT
If I have an object that implements IDisposable and I call the .Dispose method, should I also set the object to null? I know about the "using" keyword, so no need to explain it or it's benefits.
Ex:
Should I do this...
VB.NET:
SqlCommand cmd = new SqlCommand();
...do stuff with command here....
cmd.Dispose();
cmd = null;
...or...
VB.NET:
SqlCommand cmd = new SqlCommand();
...do stuff with command here....
cmd.Dispose();
...or...
VB.NET:
SqlCommand cmd = new SqlCommand();
...do stuff with command here....
cmd = null;
Thanks in advance.
CT