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
On this page of the site you can watch the video online C# switch case | C# switch statement Example | c# switch statement | c# tutorial with a duration of hours minute second in good quality, which was uploaded by the user Inform Techi 08 June 2020, share the link with friends and acquaintances, this video has already been watched 377 times on youtube and it was liked by 13 viewers. Enjoy your viewing!