Hello World
1 2 3 4 5 6 7 8 9 10 | using System; class MyApp { public static void Main(String[] args) { Console.WriteLine("Hello, World!"); } } |
Or let C# compiler generate the boiler code for you
1 | System.Console.WriteLine("Hello World!"); |
Or even add a namespace
1 2 3 4 5 6 7 8 9 10 11 12 13 | using System; namespace MyAppNameSpace { class MyApp { public static void Main(String[] args) { Console.WriteLine("Hello, World!"); } } } |
1 2 3 4 5 | // Single Line Comments /* Multi Line Comments */ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // Keywords abstract event namespace static as explicit new string base extern null struct bool FALSE object switch break finally operator this byte fixed out throw case float override TRUE catch for params try char foreach private typeof checked goto protected uint class if public ulong const implicit readonly unchecked continue in ref unsafe decimal int return ushort default interface sbyte using delegate internal sealed virtual do is short void double lock sizeof volatile else long stackalloc while enum |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // Contextual Keywords add get notnull select and global nuint set alias group on unmanaged (function pointer calling convention) ascending init or unmanaged (generic type constraint) args into orderby value async join partial (type) var await let partial (method) when (filter condition) by managed (function pointer calling convention) record where (generic type constraint) descending nameof remove where (query clause) dynamic nint required with equals not scoped yield file from |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // Numeric types // Signed sbyte svar1 = -1; short svar2 = 1; int svar3 = 3; long svar4 = 5L; nint isntPte = null; // Unsigned byte uvar = 1; ushort uvar2= 3; unit uvar4 = 5U; ulong uvar5 = 7UL; unint yvar5 = 9; // Real float rVar1 = 34.78F; double rVar2 = 34343.45453F decimal rVar3 = 34M; |