C# Fundamentals

Welcome to the C# fundamentals documentation. This section provides an introduction to the core concepts and building blocks of the C# programming language.

Introduction to C#

C# (pronounced "C sharp") is a modern, object-oriented programming language developed by Microsoft within the .NET initiative. It is a type-safe, object-oriented language that allows developers to build a wide range of applications, from desktop and web applications to mobile apps, cloud services, and games.

Key Concepts

Your First C# Program

Let's write a simple "Hello, World!" program:


using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");
    }
}
            

Data Types in Detail

C# is statically typed, meaning variable types must be declared explicitly or inferred by the compiler. Here are some fundamental data types:

Example: Variables and Output

This example demonstrates variable declaration and output:


using System;

public class VariablesExample
{
    public static void Main(string[] args)
    {
        int age = 30;
        string name = "Alice";
        double salary = 50000.50;

        Console.WriteLine($"Name: {name}");
        Console.WriteLine($"Age: {age}");
        Console.WriteLine($"Salary: {salary:C}"); // Formatted as currency
    }
}
            

Next Steps

Now that you have a grasp of the basics, you can move on to more advanced topics like: