T
Tony
Hello!
I know that the block of code below is the same as using the using clause.
I must have this kind of text because the question is about the statement
((IDisposable)reader).Dispose();
Now to my question:
If I use this statement ((IDisposable)reader).Dispose();
or reader.Dispose();
must mean exactly the same thing.
It's the method Dispose in the TextReader class that is called here because
it's not virtual.
{
TextReader reader = new StreamReader("some filename";
try
{
string line;
while((line = reader.ReadLine()) != null)
{
Console.WrileLine(line);
}
}
finally
{
if (reader != null)
{
((IDisposable)redaer).Dispose();
}
}
}
//Tony
I know that the block of code below is the same as using the using clause.
I must have this kind of text because the question is about the statement
((IDisposable)reader).Dispose();
Now to my question:
If I use this statement ((IDisposable)reader).Dispose();
or reader.Dispose();
must mean exactly the same thing.
It's the method Dispose in the TextReader class that is called here because
it's not virtual.
{
TextReader reader = new StreamReader("some filename";
try
{
string line;
while((line = reader.ReadLine()) != null)
{
Console.WrileLine(line);
}
}
finally
{
if (reader != null)
{
((IDisposable)redaer).Dispose();
}
}
}
//Tony