A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

C# (pronounced see sharp) is a multi-paradigm programming language encompassing strong typing, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines. It was developed by Microsoft within its .NET initiative and later approved as a standard by Ecma (ECMA-334) and ISO (ISO/IEC 23270:2006). C# is one of the programming languages designed for the Common Language Infrastructure.

C# is a multi-paradigm, managed, object-oriented programming language created by Microsoft in conjunction with the .NET platform. C# is also used with non-Microsoft implementations (most notably, Mono).

Versions 1.0/1.2 and 2.0 of C# were submitted and approved as both ECMA and ISO/IEC standards. As of December 2010, there are no ECMA or ISO/IEC specifications for C# 3.0 and 4.0, however language specifications are available from Microsoft (3.0 and 4.0 respectively).

The language's type system was originally static, with only explicit variable declarations allowed. However, the introduction of var (C# 3.0) and dynamic (C# 4.0) allow it to use type inference for implicit variable typing, and to consume dynamic type systems, respectively. Delegates (especially with lexical closure support for anonymous methods (C# 2.0) and lambda expressions (C# 3.0)) allow the language to be used for functional programming.

Compilation is usually to the Common Intermediate Language (CIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR); however, options like Ngen (.NET) and AOT (Mono) mean this isn't the only option. Additionally, some frameworks (e.g. the Micro Framework) act as CIL interpreters, with no JIT.

Perhaps unusually, generics in C# are provided (in part) by the runtime, unlike (for comparison) C++ templates, or Java's generics (which use type-erasure).

With the combination of Microsoft .NET for Windows (desktop/server), Mono (desktop/server/mobile), Silverlight / Moonlight (browser/mobile), Compact Framework (mobile), and Micro Framework (embedded devices), it is available for a wide range of platforms.

Hello World

using System;
class Hello
{
    static void Main() 
    {
        Console.WriteLine("Hello, World!");
    }
}

FAQs

Resources

Books

history | excerpt history

Code Language (used for syntax highlighting): lang-cs