Programming several conditions in C#
When you have to programme a piece of code which have several conditions you could do it in the following way: switch(a.name){ case “smith”: CallHim(); break; case “doyle”: SendAMessageToHim(); break; default: throw new WriteNotReachableErrorException();} If you couldn’t use constants as conditions, you will implement the logic in the following way: if(a.name == smithObject.ToString()){ CallHim();}else if(a.name == doyleObject.ToString()){ SendAMessageToHim();}else{ throw new WriteNotReachableErrorException();} But if you think now there is now other possibility to implement the logic, wait! I found recently…