![]() | ![]() |
Conditional statements are programming constructs that are used to alter the execution path of the code depending upon certain conditions. Consider an example where you are asked to build an online ticketing app and you are told that if the user is a student, he should be given a ticket at half price. On the other hand, if the user is not a student, sale the ticket at full price. Here the application is dependent on the condition that if the user is a student or not. Such conditional logic is implemented with the help of conditional statements.
In C#, there are three types of conditional statements:
In this chapter, we will study each of the aforementioned conditional statements in detail.