C# switch case | C# switch statement Example | c# switch statement | c# tutorial

Publicado em: 08 Junho 2020
no canal de: Inform Techi
377
13

What is control statement?
   • if statement in c# | if statement in c# in...  


some other videos of c#

What is c#?
   • Video  

Basic structure of c# program?
   • Basic Structure of c# program | c# basic |...  

Reading and writing in c#?
   • reading and writing in c# | c# tutorial  

Data type in c# ?
   • data type in c# | C# data type | C# data t...  

what is switch case ?

Switch case statement is a type of selection statement;

It select a particular pice of code to execute base on some condition.

It is replacement of if-else statement.

Syntax :

switch (Switch_on)
{
case 1: // code to be executed ;
break;
case 2: // code to be executed;
break;
default: // code to be executed if n doesn't match any cases
}



Example :

using System;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter Value of N1 : ");
int n1 = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter Value of N2 : ");
int n2 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Add-1 Sub-2 Mul-3 Div-4");

int op = Convert.ToInt32(Console.ReadLine());


switch (op)
{
case 1: Console.WriteLine("Sum : {0}", (n1 + n2));
break;
case 2: Console.WriteLine("Sub : {0}", (n1 - n2));
break;
case 3: Console.WriteLine("Mul : {0}", (n1 * n2));
break;
case 4: Console.WriteLine("Div : {0}", (n1 / n2));
break;
default: Console.WriteLine("Please Enter correct input!..");
break;
}


}
}


#informtechi
#controlStatement
#switchcase
#CsharpProgramming


Nesta página do site você pode assistir ao vídeo on-line C# switch case | C# switch statement Example | c# switch statement | c# tutorial duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Inform Techi 08 Junho 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 377 vezes e gostou 13 espectadores. Boa visualização!