Why set it to null first ?
[EDIT]
there was this code about reading some file..it was like
StreamReader sr=null;
StreamReader sr= new StreamReader("file.txt");
I asked why would you set "SR" as null first BEFORE referencing the file u wanna read
Why set it to null first ?
[EDIT]
there was this code about reading some file..it was like
StreamReader sr=null;
StreamReader sr= new StreamReader("file.txt");
I asked why would you set "SR" as null first BEFORE referencing the file u wanna read
There is no need to do that... in fact, the code above should give you a compile error as sr is already defined.
And you should probably write it as
using (var sr = new StreamReader("file.txt"))
{
//code here
}
in order to make sure it is properly disposed after usage (lookup IDisposable)