0
In C#, variable decleared in side try block is local variable or something else.
I have tried to get input under a try block and use it outside. But It throws error in sololearn compilar.
2 Answers
+ 4
show us your code.
instead of try-catch, a simpler way is to use TryParse methods if you're doing conversions.
0
You need to instance the variable outside the try then you will be able to return it, if everything works, other hand you will get the catch block where you need to handle the variable like setting up as null or something, or just throw;