Kithoras Carzyl Kithoras Carzyl - 5 months ago 45
C# Question

C# - Can/Should I simplify/alter this code snippet?

I got the following code in my program:

#region Handle

goto Handled;
else if(HandlePath(input))
goto Handled;
else if(HandleGeneratedLink(input))
goto Handled;
else ...
return; // Break if not handled



Im not very happy with this, because to me it seems like a cheat to use a goto in every second line.
Is there a common way to write such a thing or is this a valid solution?

Jek Jek

You can also do something like this:

if (!HandleLink(input) && !HandlePath(input) && !HandleGeneratedLink(input)) {
// put the code related to "Handled" here