I have written a piece of lousy code in C#.NET and i want to optimize it.
All i can think of at the moment is to separate the common portions into a separate method.
Code :
if(condition1)
{
switch(condition)
case 'A' : //Some code
break;
case 'B' : //Some code
break;
case 'C' : //Some code
break;
}
else if(condition2)
{
switch(condition)
case 'a' : //Some code
break;
case 'B' : //Some code
break;
case 'C' : //Some code
break;
}
Note that the case statements conditions for case 'B' and case 'C' are common.
Any help on improving the code is deeply appreciated.
switchstatements and put theif/elseinside the branches where applicable?