calling methods if previous call success
- by New Developer
I my c# program I have to perform 5 steps(tasks) sequentially. basically these five should execute one after the other only the previous task performed is success. Currently I have done it in following style. But this is not very good code style to follow.
var isSuccess=false;
isSuccess=a.method1();
if(isSuccess)
isSuccess=a.method2();
if(isSuccess)
isSuccess=a.method3();
if(isSuccess)
isSuccess=a.method4();
if(isSuccess)
isSuccess=a.method5();
How can I re factor this code. What is the best way I can follow?