John Baird
Coatesville, Pennsylvanie, États-Unis
Information générale
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Network:
Windows 2003 Server
>>I have controller methods where sometimes I return a View and othertimes I RedirectToAction. So, two returns are required.
>>
>Right now I am working on the conversion of our VFP class library into C# dll. In VFP we checked parameters at the top and returned. There were also many other return exists in the methods.
>
>I already converted a few by not using early returns, but I think in general it should be OK - otherwise it's very hard to use if else if else nested logic.
No its not....
You set a variable. ... retVal ... you initialize it however you want, then in your flow, instead of returning, you assign the value to retVal and at the end you return retVal.
I hate code with multiple return points and numerous out parameters. You cant test it and you end up with nothing but a spaghettie code mix...
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement