Total Page Preview:   000000000401

What is if statement in C-Sharp in English and Hindi

 

If statement in C-Sharp in English:

In C#, the if statement is used to test a condition and execute a block of code if the condition is true. If the condition is false, the block of code is skipped

Here's an example of using the if statement in C#:

 
In the above example, we are using the if statement to test if the value of the number variable is greater than zero. If the condition is true, the message "The number is positive." is displayed on the console.
We can also add an else statement to the if statement to execute a block of code if the condition is false.
Here's an example:
 
In the above example, the condition is false because the value of the number variable is less than zero. So, the message "The number is not positive." is displayed on the console.
We can also use the else if statement to test multiple conditions.
Here's an example:
 
In the above example, we are testing three conditions using the if, else if, and else statements. Depending on the value of the number variable, the appropriate message will be displayed on the console.
 

If statement in C-Sharp in Hindi:

C# mai if statement ka use kisi condition ko test karne aur agar condition true hoti hai to ek block of code ko execute karne ke liye kiya jata hai. Agar condition false hoti hai to code ka block skip ho jata hai.
Yaha C# mai if statement ka ek example diya gaya hai:
 
 
Upar ke example me hum if statement ka use karke test kar rahe hai ki kya number variable ki value zero se badi hai ya nahi. Agar condition true hoti hai to console par message "The number is positive." print ho jayega.
Hum if statement ke sath else statement ka use karke condition false hone par ek block of code ko execute kar sakte hai. Yaha ek example hai:
 
 
Upar ke example me condition false hai kyuki number variable ki value zero se choti hai. Isliye console par message "The number is not positive." print ho jayega.
Hum else if statement ka use karke multiple conditions test kar sakte hai. Yaha ek example hai:

Upar ke example me hum if, else if, and else statements ka use karke teeno conditions ko test kar rahe hai. number variable ki value ke anusar sahi message console par print ho jayega.

 

 

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: