Skip to content

Instantly share code, notes, and snippets.

@bharathmuddada
Created July 14, 2022 06:18
Show Gist options
  • Save bharathmuddada/99353f80c0e3eb37c08cdbe5d46af891 to your computer and use it in GitHub Desktop.
Save bharathmuddada/99353f80c0e3eb37c08cdbe5d46af891 to your computer and use it in GitHub Desktop.
Example program for switch case
public class SwitchCaseExample
{
public static void Main(String[] args)
{
Console.WriteLine("Enter any of the 3 seasons Summer , Winter, Rainy ");
string season = Console.ReadLine();
switch (season) {
case "Summer":
Console.WriteLine($"{season} lasts from March to May");
break;
case "Winter":
Console.WriteLine($"{season} lasts from December to January");
break;
case "Rainy":
Console.WriteLine($"{season} lasts from June to September");
break;
default:
Console.WriteLine("Enter a valid season");
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment