Tuesday, 3 September 2013

Move to previous given line in code

Move to previous given line in code

I need to run the same code if a particulate exception is occurred. So I
tried using goto, but with goto statement I cant move to a line before the
goto statement is located
Sample code,
try
{
top:
//Code
}
catch (Exception ex)
{
if (ex.Message.Substring(1, 5) == "error")
{
goto top: //Error - Can not resolve symbol `top`
goto bottom: //OK
}
}
bottom:
//Code
}
How to execute a previous line of code?

No comments:

Post a Comment