S
Steven Blair
Hi,
Here is a small example function. What I would like to know is when I
should be using null:
private bool MyTestFunc(string Message)
{
StreamWriter sw=null;
string str=null;
sw = new StreamWriter(FILE_PATH,true);
//Do some stuff with the SW
str = String.Format(@"{0}|{1}|",CLASS_NAME,message);
sw.WriteLine(str);
sw.Close();
//Not sure what to do here, but here is my guess
sw=null;
str=null;
//If I didnt set these to null, would that mean the
//The GC wouldnt clean these objects up?
return true;
}
Any help on this would be appreciated.
Regards,
Steven
Here is a small example function. What I would like to know is when I
should be using null:
private bool MyTestFunc(string Message)
{
StreamWriter sw=null;
string str=null;
sw = new StreamWriter(FILE_PATH,true);
//Do some stuff with the SW
str = String.Format(@"{0}|{1}|",CLASS_NAME,message);
sw.WriteLine(str);
sw.Close();
//Not sure what to do here, but here is my guess
sw=null;
str=null;
//If I didnt set these to null, would that mean the
//The GC wouldnt clean these objects up?
return true;
}
Any help on this would be appreciated.
Regards,
Steven