+ 1
defining int type before try_catch
in this below code: int result=0; int num1 = 8; int num2 = 4; try { result = num1 / num2; } catch (DivideByZeroException e) { Console.WriteLine("Error"); } finally { Console.WriteLine(result); } must the int result be defined by 0 (not declared) before entering try_catch. isnt it just enough to be declared and defined later in try?
3 odpowiedzi
+ 6
yup I think so
+ 1
me too, so tried my desired code and it gave me error 😐