Languages Features Calendar About Lists Add Language
GitHub icon



C# is a programming language created in 2000 by Anders Hejlsberg.

C# (pronounced as 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. Read more on Wikipedia...

Try now: Riju · Replit

#14on PLDB 22Years Old 217.3kUsers

Example code from Riju:

class main { static void Main(string[] args) { System.Console.WriteLine("Hello, world!"); } }

Example code from hello-world:

System.Console.WriteLine("Hello World");

Example code from Linguist:

using System; namespace MongoDB.Serialization.Descriptors { internal class BsonPropertyValue { public bool IsDictionary { get; private set; } public Type Type { get; private set; } public object Value { get; private set; } public BsonPropertyValue(Type type, object value, bool isDictionary) { Type = type; Value = value; IsDictionary = isDictionary; } } }

Example code from Wikipedia:

using System.Windows.Forms; class Program { static void Main(string[] args) { MessageBox.Show("Hello, World!"); System.Console.WriteLine("Is almost the same argument!"); } }

Keywords in C#

abstract add alias as ascending async await base bool break byte case catch char checked class const continue decimal default delegate descending do double dynamic else enum event explicit extern false finally fixed float for foreach from get global goto group if implicit in int interface internal into is join let lock long namespace new null object operator orderby out override params partial private protected public readonly ref remove return sbyte sealed select set short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked unsafe ushort using value var virtual void volatile where while yield

Language features

Feature Supported Example Token
Conditionals ✓
Access Modifiers ✓
Switch Statements ✓
Exceptions ✓
Constants ✓
Classes ✓
While Loops ✓
Case Sensitivity ✓
Function Composition ✓
// Call example:
//   var c = Compose(f, g);
//   Func g = _ =>  ...
//   Func f = _ => ...

Func Compose(Func f, Func g) => _ => f(g(_));
Default Parameters Pattern ✓
public void ExampleMethod(string optionalstr = "default string") {}
Line Comments ✓
// A comment
Dispose Blocks Pattern ✓
using (Resource resource = GetResource())
   // Perform actions with the resource.
Module Pattern ✓
// In C#, namespaces are the semi-equivalent of Java's packages.
namespace com.test
   class Test {}
Operator Overloading ✓
Namespaces ✓
namespace MyNamespace
    class MyClass
        public void MyMethod()
            System.Console.WriteLine("Creating my namespace");
File Imports ✓
using static System.Console;
using static System.Math;
class Program
    static void Main()
        WriteLine(Sqrt(3*3 + 4*4));
Type Casting ✓
Animal animal = new Cat();

Bulldog b = (Bulldog) animal;   // if (animal is Bulldog), stat.type(animal) is Bulldog, else an exception
b = animal as Bulldog;          // if (animal is Bulldog), b = (Bulldog) animal, else b = null

animal = null;
b = animal as Bulldog;          // b == null
Directives ✓
#define MAX_CLIENTS 200
int array[MAX_CLIENTS];

Generators ✓
// Method that takes an iterable input (possibly an array)
// and returns all even numbers.
public static IEnumerable GetEven(IEnumerable numbers) {
    foreach (int i in numbers) {
        if ((i % 2) == 0) {
            yield return i;
Constructors ✓
public class MyClass
    private int a;
    private string b;

    // Constructor
    public MyClass() : this(42, "string")

    // Overloading a constructor
    public MyClass(int a, string b)
        this.a = a;
        this.b = b;
// Code somewhere
// Instantiating an object with the constructor above
MyClass c = new MyClass(42, "string");
Generics ✓
// Declare the generic class.
public class GenericList
    public void Add(T input) { }
class TestGenericList
    private class ExampleClass { }
    static void Main()
        // Declare a list of type int.
        GenericList list1 = new GenericList();

        // Declare a list of type string.
        GenericList list2 = new GenericList();

        // Declare a list of type ExampleClass.
        GenericList list3 = new GenericList();
        list3.Add(new ExampleClass());
Pointers ✓
// Pointers supported only under certain conditions.
// Get 16 bytes of memory from the process's unmanaged memory
IntPtr pointer = System.Runtime.InteropServices.Marshal.AllocHGlobal(16);
Async Await ✓
public async Task FindPageSize(Uri uri) 
    byte[] data = await new WebClient().DownloadDataTaskAsync(uri);
    return data.Length;
MultiLine Comments ✓
/* A comment
/* */
Print() Debugging ✓
Console.WriteLine("This is C#");
Assignment ✓
int i = 42;
Integers ✓
int i = 42;
Booleans ✓ true false
Strings ✓
"hello world"
Comments ✓
// This is a comment
Semantic Indentation Ï´

Trending C# repos on GitHub

repo stars description
WaveFunctionCollapse 12814 Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics.
osu 3486 rhythm is just a *click* away!
samples 618 Sample code and snippets used in the .NET documentation
ShadowsocksR-Windows 677 【自用】Forked from shadowsocksr and shadowsocksrr
coreclr 11992 "CoreCLR is the runtime for .NET Core. It includes the garbage collector JIT compiler primitive data types and low-level classes."
EquinoxProject 2873 "Full ASP.NET Core 2.2 application with DDD CQRS and Event Sourcing"
confluent-kafka-dotnet 1172 Confluent's Apache Kafka .NET client
dotnetcore-microservices-poc 529 Very simplified insurance sales system made in a microservices architecture using .NET Core
awesome-dotnet-core 9843 "🐝 A collection of awesome .NET core libraries tools frameworks and software"
jellyfin 3666 The Free Software Media System
dnSpy 11499 .NET debugger and assembly editor
WTM 932 WTM框架是针对中小规模后台管理系统的开发利器。基于DotNetCore,实现0编码创建项目,0编码生成业务模块。框架严格遵循MVVM的开发模式,并深得MVVM的精髓。对于新手,可以快速上手搭建项目;对于高手,可以把那些繁琐重复的工作交给框架生成,专心攻克需求难点。框架经过数十个真实项目检测,可以极大提高开发效率,降低开发成本。
NorthwindTraders 2559 Northwind Traders is a sample application built using ASP.NET Core and Entity Framework Core.
EntityFrameworkCore 8039 Entity Framework Core is a lightweight and extensible version of the popular Entity Framework data access technology
appcenter 367 Central repository for App Center open source resources and planning.
azure-powershell 1598 Microsoft Azure PowerShell
Hangfire 5046 An easy way to perform background job processing in your .NET and .NET Core applications. No Windows Service or separate process required
grandnode 797 Free and Open Source Ecommerce Shopping Cart solution based on ASP.NET CORE and MongoDB
QuasarRAT 2618 Remote Administration Tool for Windows
gui.cs 2674 Console-based user interface toolkit for .NET applications.
CAP 3096 "Distributed transaction solution in micro-service base on eventually consistency also an eventbus with Outbox pattern"
MaterialDesignInXamlToolkit 7150 "Google's Material Design in XAML & WPF for C# & VB.Net."
v2rayN 581
DotNetty 2571 "DotNetty project – a port of netty event-driven asynchronous network application framework"
microservices-demo 5767 "Sample cloud-native application with 10 microservices showcasing Kubernetes Istio gRPC and OpenCensus. Provided for illustration and demo purposes."

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub