i would like to check if there is a way to stop the console from closing when there is a exception?
This should work:
static void Main(string[] args)
{
try
{
// put all code in here ...
try
{
File.Open("Not An Existing File", FileMode.Open); // test an exception
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
finally
{
Console.Write("Press Enter to close window ...");
Console.Read();
}
}
- Wayne
No comments:
Post a Comment