Learn C# Programming

Master C# programming from basics to advanced concepts with our comprehensive tutorial series. Perfect for beginners and experienced developers.

C# if...else Statement

The if...else statement allows you to execute different blocks of code based on conditions.

Basic if Statement

int age = 18;

if (age >= 18)
{
    Console.WriteLine("You are an adult");
}

if...else Statement

int score = 85;

if (score >= 90)
{
    Console.WriteLine("Grade: A");
}
else
{
    Console.WriteLine("Grade: B or lower");
}

if...else if...else Statement

int score = 85;

if (score >= 90)
{
    Console.WriteLine("Grade: A");
}
else if (score >= 80)
{
    Console.WriteLine("Grade: B");
}
else if (score >= 70)
{
    Console.WriteLine("Grade: C");
}
else if (score >= 60)
{
    Console.WriteLine("Grade: D");
}
else
{
    Console.WriteLine("Grade: F");
}

Nested if Statements

int age = 25;
bool hasLicense = true;

if (age >= 18)
{
    if (hasLicense)
    {
        Console.WriteLine("You can drive");
    }
    else
    {
        Console.WriteLine("You need a license to drive");
    }
}
else
{
    Console.WriteLine("You are too young to drive");
}

Logical Operators in Conditions

int age = 25;
bool hasJob = true;
double income = 50000;

// AND operator
if (age >= 18 && hasJob)
{
    Console.WriteLine("Eligible for loan");
}

// OR operator
if (age >= 65 || income < 20000)
{
    Console.WriteLine("Eligible for discount");
}

// NOT operator
if (!hasJob)
{
    Console.WriteLine("Unemployed");
}

💡 Best Practices

  • Always use braces {} even for single statements
  • Keep conditions simple and readable
  • Use logical operators to combine conditions
  • Consider using switch for multiple discrete values

Frequently Asked Questions

C# is a modern, object-oriented programming language developed by Microsoft. It's part of the .NET framework and is used for developing various applications including web applications, desktop software, mobile apps, and games.

No! You can start learning C# immediately using our online compiler. For advanced development, you can install the .NET SDK and Visual Studio or VS Code on your computer.

Yes! C# has a clean syntax and strong type system that makes it beginner-friendly. Our tutorial starts from the basics and gradually progresses to advanced topics.

C# is versatile and can be used to build web applications (ASP.NET), desktop applications (WPF, WinForms), mobile apps (Xamarin), games (Unity), APIs, microservices, and much more.

The time varies based on your programming background. Complete beginners can learn the basics in 2-3 months with consistent practice. Our structured tutorial helps you progress systematically.

Master C# Programming with Our Comprehensive Tutorial

Our C# programming tutorial is designed to take you from a complete beginner to an advanced developer. Whether you're looking to build web applications, desktop software, or mobile apps, C# provides the foundation you need for modern software development.

Start with the basics like variables, data types, and control structures, then progress to advanced topics including object-oriented programming, LINQ, async programming, and more. Each lesson includes practical examples and exercises to reinforce your learning.

Join thousands of developers who have learned C# programming through our step-by-step tutorials. Begin your journey today and unlock the power of .NET development.