vendredi 1 décembre 2017

C# - How to avoid multiple if calls

I have the following code

var response = method1();
if(response.Successful) response = method2();
if(response.Successful) response = method3();
if(response.Successful) response = method4();

return response

And while I do get the purpose of that I was wondering if there is a better way to do it?, maybe a pattern, but without harming readability.

Aucun commentaire:

Enregistrer un commentaire