Welcome to Kodecsharp
Kodecsharp website provides beginners to C# programming some examples to use the C# API (Application Programming Interface) to develop applications. Learning from some examples will hopefully decrease the time required to learn C#.
In this website you will find a lot of examples which grouped by the C# API namespace. You can easily find a solution to your problem and the entire examples provided here are free. Enjoy your study, come and visit the site regularly to find more and more examples of C# code.
You can also fork the examples published on this website from our GitHub website on the following address: https://github.com/wsaryada/kodecsharp
--
I Wayan Saryada
Kodecsharp Webmaster
Latest Code Examples
Most Viewed Examples
How do I use switch statement?
The example below demonstrate a simple use of the switch statement. A switch statement can be a good replacement for a long if-else-if-else selection statement.
A switch statement handles multiple selection by passing control to one of its case statement within its body. Selection will be handled by the case statement that matches the value of the switch. switch statements can have many case but each case should have a unique value.
Each of case block should be closed by the break statement. This include the last statement whether it is a case or a default block.
If no case condition matched the switch value the control will be transferred to default block. If the default is not available the control will be transferred out side the switch.
Here is an example result of the program:
Please enter week day: 4 Day name: Wednesday