Strategy method or Switch statement in C# - Online Free Computer Tutorials.

'Software Development, Games Development, Mobile Development, iOS Development, Android Development, Window Phone Development. Dot Net, Window Services,WCF Services, Web Services, MVC, MySQL, SQL Server and Oracle Tutorials, Articles and their Resources

Monday, June 13, 2011

Strategy method or Switch statement in C#

In programming, use of conditional operation is one of the common scenario. ifswitch are few of those control statements which help us to do the conditional operation. If we think about a situation, in where we need to do multiple tasks for each of the condition for example, if user select display Computer details then we need to write few statements to display Computer information or if they select to display Processor information also require to write few statements. To make code elegant we will probably move all those statements on its own method block and run those methods based on the condition.
 
To describe the situation I created an enum which defines our conditions,

No comments:

Post a Comment