You need to sign in to do that
Don't have an account?
Hitesh Algamwar
how we can access the variable which is created in try block and we need to use than in the catch block.
for example :-
class A{
try {
string a = abc ;
}catch(exception e)
{
// now here i want to create one object record
object b = new object ();
b.stringval = now here i need to update the value which in string a in try block.
}
}
class A{
try {
string a = abc ;
}catch(exception e)
{
// now here i want to create one object record
object b = new object ();
b.stringval = now here i need to update the value which in string a in try block.
}
}
No you cannot access the variable which is in try block in catch block. You can try somethiing like this.
If you define the variable outside the try block so you can use the variable any where
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
No you cannot access the variable which is in try block in catch block. You can try somethiing like this.
If you define the variable outside the try block so you can use the variable any where
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,