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)r eader).Dispose( );
Now to my question:
If I use this statement ((IDisposable)r eader).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("s ome filename";
try
{
string line;
while((line = reader.ReadLine ()) != null)
{
Console.WrileLi ne(line);
}
}
finally
{
if (reader != null)
{
((IDisposable)r edaer).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)r eader).Dispose( );
Now to my question:
If I use this statement ((IDisposable)r eader).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("s ome filename";
try
{
string line;
while((line = reader.ReadLine ()) != null)
{
Console.WrileLi ne(line);
}
}
finally
{
if (reader != null)
{
((IDisposable)r edaer).Dispose( );
}
}
}
//Tony
Comment