harry code

harry code

  • NA
  • 124
  • 22.8k

Using finally block woth out catch block

Mar 31 2018 7:50 AM
Hi...I want to use  try block and finally block..with out using catch block.
I am able to execute finally block when i am using cntr+F5.....But not when directly using F5..Is it Manditory to use cntrl??????
 
My code is below.....
 
 
 
public void Ex()
{
try
{
Console.WriteLine("enter the first number");
int a = int.Parse(Console.ReadLine());
Console.WriteLine("enter the second number");
int b = int.Parse(Console.ReadLine());
int c = a / b;
Console.WriteLine("the value is:" + c.ToString("c"));
}
finally
{
Console.WriteLine("Finally block is executed");
}
}
 
 

Answers (9)