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
Sur cette page du site, vous pouvez voir la vidéo en ligne C# switch case | C# switch statement Example | c# switch statement | c# tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Inform Techi 08 juin 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 377 fois et il a aimé 13 téléspectateurs. Bon visionnage!