Code is always executed in the using statement if instantiating does not raise an exception.
Keep this in mind.
int Flag;
using (StreamReader reader = new StreamReader(FileName, Encoding.GetEncoding("iso-8859-1"), true))
{
Flag = 1;
}
if(Flag == 1)
{
}
However, there is a way to ensure that the next part of the code is executed. Using the try statement will give you the opportunity to verify that the flag is set. This may not be what you want to do, but based on your code it will make sure the flag is set. Perhaps you need a different logic.
int Flag;
try
{
using (StreamReader reader = new StreamReader(FileName, Encoding.GetEncoding("iso-8859-1"), true))
{
Flag = 1;
}
}
catch (Exception e)
{
Flag = -1;
}
if(Flag == 1)
{
}
Bauss source
share