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
Auf dieser Seite können Sie das Online-Video C# switch case | C# switch statement Example | c# switch statement | c# tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Inform Techi 08 Juni 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 377 Mal angesehen und es wurde von 13 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!