Total Page Preview:   000000000341

What is the switch statement in C-Sharp in English and Hindi

 

 

Switch statement in C-Sharp in English:

In C#, the switch statement is a control structure used to execute different sections of code based on the value of a single expression. It allows you to specify multiple cases, and execute different code for each case.
Here is an example of a switch statement in C#:

In this example, we define an integer variable day and initialize it to 2. We then use a switch statement to check the value of day and assign the corresponding day name to the dayName variable. The break keyword is used to indicate the end of each case. If none of the cases match the value of day, the default case is executed and dayName is assigned the value "Invalid day". Finally, we print the value of dayName to the console.
 
When executed, this code will output: "Today is Tuesday".
 
Switch statement in C-Sharp in Hindi:
 
Switch statement C# me ek control statement hai, jo ek expression ki value ke hisab se kuch actions execute karta hai. Switch statement ka use kisi variable ya expression ke multiple values ke comparison ke liye kiya jata hai.
Yaha ek simple example hai, jisme switch statement ka use kiya gaya hai:
 
 
Is example me humne ek integer variable day ka value 3 set kiya hai. Uske baad humne switch statement ka use kiya hai day variable ke value ke hisab se dayName variable ko set karne ke liye. Agar day variable ke value 3 hota hai, to dayName ko "Wednesday" set kiya jata hai. Switch statement ka use default case ke liye bhi kiya gaya hai, jo case ke matches nahi hone par execute hota hai.

 

 

 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: