c# switch
int caseSwitch = 1;
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}
c# switch
int caseSwitch = 1;
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}
c# switch example
switch (iGender)
{
case 1:
LabelOne.Text = "Male";
break;
case 2:
LabelOne.Text = "Female";
break;
switch c#
//This is the supreme way to make a console app with a switch.
using System;
namespace Example
{
class Program
{
static void Main(string[] args)
{
//Greats the user.
Console.WriteLine("Hello!");
Console.WriteLine();
//An infinite loop for continues command reading.
while (true)
{
//Asks for input on a line starting with >>.
Console.Write(">> ");
input = Console.ReadLine();
//Checks if the user wants to exit.
if (input == "Close") break;
//Gets the first word of the line and puts it in command.
var command = input.Split(' ')[0];
//sets up a switch for all the possible commands
switch (command)
{
case "log":
//This is entered if log is submited into the Console.
Console.WriteLine("Not implemented");
break;
case "":
//Leaves the user alone. This is needed because otherwise it would
//cosnider "" as the defualt and print Unknown command.
break;
default:
Console.WriteLine("Unknown command.");
Console.WriteLine();
break;
}
}
}
}
}
C# Switch
int var = 3;
switch (var)
{
case 1:
Console.WriteLine("Ahoy!");
break;
case 2:
Console.WriteLine("Hi!");
break;
case 3:
Console.WriteLine("HELLO!");
break;
}
//Output: HELLO!
c# switch
scale = exponent switch
{
int n when (n >= 6 && n < 9) => "Million",
int n when (n >= 9 && n < 12) => "Billion",
int n when (n >= 12 && n < 15) => "Trillion",
int n when (n >= 15 && n < 18) => "Quadrillion",
int n when (n >= 18 && n < 21) => "Quintillion",
int n when (n >= 21 && n < 24) => "Sextillion",
int n when (n >= 24 && n < 27) => "Septillion",
int n when (n >= 27 && n < 30) => "Octillion",
30 => "Nonillion",
_ => "",
};
c# switch
int caseSwitch = 1;
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us