Conditional Statements in C#
Introduction
In this lesson, you will learn conditional statements in C# for beginners. These statements help your program make decisions based on conditions.
What are Conditional Statements?
Conditional statements are used to execute different code based on conditions.
Types of Conditional Statements in C#
if Statement
int age = 18;
if (age >= 18)
{
Console.WriteLine("You are eligible to vote");
}
if-else Statement
int age = 16;
if (age >= 18)
{
Console.WriteLine("Eligible");
}
else
{
Console.WriteLine("Not Eligible");
}
else if Statement
int marks = 75;
if (marks >= 90)
{
Console.WriteLine("A Grade");
}
else if (marks >= 60)
{
Console.WriteLine("B Grade");
}
else
{
Console.WriteLine("C Grade");
}
Real-World Use
- Login validation
- Eligibility checks
- Decision making in apps
Key Points
- Used to make decisions in programs
- Based on true or false conditions
- Improves program logic
Internal Links
Course Page: .NET Course for Beginners



