C# Programming Language: Switch Statements

Switch Statement

int number = 1;
switch(number)
{
case 1:
Console.WriteLine("One");
break;
case 2:
Console.WriteLine("Two");
break;
}
Output:
One
int number = 2;
switch(number)
{
case 1:
Console.WriteLine("One");
break;
case 2:
Console.WriteLine("Two");
break;
}
Output:
Two

Break Keyword in the Switch Statement

Default Keyword in the Switch Statement

int number = 3;
switch(number)
{
case 1:
Console.WriteLine("One");
break;
case 2:
Console.WriteLine("Two");
break;
default:
Console.WriteLine("None of the Above");
break;
}
Output:
None of the Above

Conclusion

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Incident Review: You Can’t Deploy Binaries That Don’t Exist — Honeycomb

Photo of honeycomb

Announcing the UniFyre Wallet and PhoenixDAO Listing Partnership

A beam cross-section calculator BeamSection

Model your Azure Synapse Analytics Data Warehouse

Football & WebSec: League standings based on SSL security

LGMVIP-THE INTERNSHIP EXPERIENCE BLOG

Ending educational poverty

PHP den JAVA ya

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jesse L

Jesse L

More from Medium

C-Sharp c# cheatsheet

1.6 C# keywords

Creating readable and maintainable methods in your code

C# Programming — Operators (Lesson 02)