Kithoras Carzyl Kithoras Carzyl - 3 years ago 139
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
Answer Source

You can also do something like this:

if (!HandleLink(input) && !HandlePath(input) && !HandleGeneratedLink(input)) {
// put the code related to "Handled" here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download