{}const=>[]async()letfn</>var
BasicsDevelopmentOverview

C# is a powerful language for creating applications, games and web services! 🎮

C# is a modern and powerful programming language developed by Microsoft. It is ideal for creating games (Unity), desktop programs and web applications. In this article you will learn how to install C#, work with variables, loops, conditions and write your first programs!

К

Kodik

Author

3 min read

What is C#? 🚀

C# (Si Sharp) is a modern, object-oriented programming language created Microsoft. It is widely used in development desktop programs, web applications, mobile applications and games. If you want to develop on Unity, then you can't do without C#! 🎮

Why study C#? 🔥

  • Simplicity and power: clear syntax, similar to Java and C++.

  • Wide application: from games to corporate software.

  • Integration with .NET: allows you to write reliable and fast applications.

  • Game development: language #1 for Unity.

🔥 100,000+ students already with us

Tired of reading theory?
Time to code!

Kodik — an app where you learn to code through practice. AI mentor, interactive lessons, real projects.

🤖 AI 24/7
🎓 Certificates
💰 Free
🚀 Start learning
Joined today

How to install C#? 💻

To work with C# you will need:

How to check if C# is installed? 🛠

Open the terminal and enter:

dotnet --version

If .NET is installed, the SDK version will appear.

C# Syntax Basics 📚

1. Variables 📦

In C#, variables are strictly typed, for example:

Example of declaring variables:

using System;

class Program {
    static void Main() {
        string name = "Alice"; // Text variable
        int age = 25; // Integer
        double pi = 3.14; // Floating point number

        Console.WriteLine($"Name: {name}, Age: {age}, Pi: {pi}");
    }
}

2. Data output 📤

To display information, use Console.WriteLine().

Example:

using System;

class Program {
    static void Main() {
        Console.WriteLine("Hello, world!");
    }
}

3. Conditional operators (if...else) 🧐

Allow the program to make decisions.

Example:

using System;

class Program {
    static void Main() {
        int age = 20;

        if (age >= 18) {
            Console.WriteLine("You're an adult!");
        } else {
            Console.WriteLine("You're still a child.");
        }
    }
}

4. Loops (for, while) 🔄

Loops allow you to repeat actions.

Example:

using System;

class Program {
    static void Main() {
        for (int i = 1; i <= 5; i++) {
            Console.WriteLine(i);
        }
    }
}

5. Functions 📐

Functions help to structure the code.

Example:

using System;

class Program {
    static int Square(int x) {
        return x * x;
    }

    static void Main() {
        Console.WriteLine("Square of the number 5: " + Square(5));
    }
}

Simple projects in C# 💡

1. Random number generator 🎲

The program generates a random number from 1 to 100.

using System;

class Program {
    static void Main() {
        Random random = new Random();
        int number = random.Next(1, 101);
        Console.WriteLine("Random number: " + number);
    }
}

2. Multiplication table 📊

The program displays a multiplication table from 1 to 10.

using System;

class Program {
    static void Main() {
        for (int i = 1; i <= 10; i++) {
            for (int j = 1; j <= 10; j++) {
                Console.Write($"{i * j}\t");
            }
            Console.WriteLine();
        }
    }
}

3. Counting the number of characters in a string 🔢

The program counts the characters in the string.

using System;

class Program {
    static void Main() {
        string text = "Hello, C#!";
        Console.WriteLine("Number of characters: " + text.Length);
    }
}

4. Checking the number for evenness 🔍

The program determines whether the number is even.

using System;

class Program {
    static void Main() {
        int number = 42;
        if (number % 2 == 0) {
            Console.WriteLine($"{number} - even number");
        } else {
            Console.WriteLine($"{number} - odd number");
        }
    }
}

5. Calculating the factorial of a number 🎯

This code calculates the factorial of a given number.

using System;

class Program {
    static int Factorial(int n) {
        int result = 1;
        for (int i = 1; i <= n; i++) {
            result *= i;
        }
        return result;
    }

    static void Main() {
        Console.WriteLine("Factorial 5: " + Factorial(5));
    }
}

Conclusion 🎉

C# is a powerful language for creating games, desktop applications and web services. In this article, we have covered the basics: variables, input/output, conditions, loops, and functions. Now you can write your first programs! 🚀

The more you practice, the better your code becomes. Experiment, try new tasks and master programming! Good luck learning C#! 😊

🎯Stop procrastinating

Liked the article?
Time to practice!

In Kodik, you don't just read — you write code immediately. Theory + practice = real skills.

Instant practice
🧠AI explains code
🏆Certificate

No registration • No card