C# - a modern, open-source programming language | .NET (original) (raw)

The modern, innovative, open-source programming language for building all your apps.

Get started

This page doesn't work on Internet Explorer. We recommend you try the new Microsoft Edge browser.

Why C#

C# is a modern, innovative, open-source, cross-platform object-oriented programming language and one of the top 5 programming languages on GitHub.

Do you have experience with JavaScript, Java, or C++? You'll find C# instantly familiar, and you'll enjoy its evolving features including type safety, generics, pattern matching, async, records, and more.

We hope you'll fall in love with C# from the very first keystroke.

Try C#

C# documentation

Press Alt+F1 for accessibility options.

            `Console.WriteLine("Hello World");

var names = new[] { "Ana", "Felipe", "Emillia" }; foreach(var name in names) { Console.WriteLine($"Hello {name}"); }`

Success! You can continue to the next step.

Press Alt+F1 for accessibility options.

            `var (name, price, perPackage) = ("pizza dough", 1.99m, 3);

var date = DateTime.UtcNow;

Console.WriteLine( $"On {date.ToLongDateString()} at {date.ToShortTimeString()}, \n"+ $"the price of {name.ToUpper()} \n" + $"was {price} per {perPackage} packages.");`

Success! You can continue to the next step.

Press Alt+F1 for accessibility options.

            `var names = new[] { "Ana", "Felipe", null, "Emillia" };

names.Where(name => name?.Length > 5) .OrderBy(name => name) .ToList() .ForEach(Console.WriteLine);`

Success! You can continue to the next step.

public static double ComputeArea(object shape)
    => shape switch
    {
        Square s => s.Side * s.Side,
        Circle c => c.Radius * c.Radius * Math.PI,
        Rectangle r => r.Height * r.Length,

        _ => throw new ArgumentException(
                message: "Unrecognizable shape",
                paramName: nameof(shape))
    };

Person person = new("Nancy", "Davolio");

Console.WriteLine(person);
// Output: Person { FirstName = Nancy, LastName = Davolio }

public record Person(string FirstName, string LastName);

Productive developer environment

Build your apps faster with world-class developer tools that help you write precise, accurate, and maintainable code the first time.

Use a wide variety of tools that fit your development style available on every platform including Visual Studio Code (an advanced code editor), Visual Studio (a powerful IDE), command-line tools, and other popular tools.

Learn about tools for C#

Build anything with C#

C# is the most popular language for .NET development. With .NET you can target any application type running on any platform. Reuse your skills, code, and favorite libraries across all of them in a familiar environment. That means you can build apps faster, with less cost.

From mobile applications running on iOS and Android, to enterprise server applications running on Windows Server and Linux, or high-scale microservices running in the cloud, .NET provides a solution for you.

Learn about the .NET platform

Learn C# with developers

Explore the concepts and syntax of the C# programming language with live coding demos in our C# for Beginners video series.

Once you learn the basics, explore other lessons at the .NET videos page where you can learn to build any type of app with C#.

Browse all lessons

Performance where it matters

.NET is fast. Really fast! That means applications provide better response times and require less compute power.

The popular TechEmpower benchmark compares web application frameworks with tasks like JSON serialization, database access, and server side template rendering - .NET performs faster than any other popular framework.

Made it this far, but not ready to install?

Our in-browser tutorial will get you started learning C# today. No install needed.

Get started