diff --git a/Csharp/examples/StaticUsingCSharp.cs b/Csharp/examples/StaticUsingCSharp.cs new file mode 100644 index 00000000..90fd8726 --- /dev/null +++ b/Csharp/examples/StaticUsingCSharp.cs @@ -0,0 +1,8 @@ +// use 'static' keyword to do not specifying 'Console' class +using static System.Console; + +// use WriteLine() method without specifying 'Console' class +WriteLine("Hello World"); + +// Include this line to keep the console from closing right after printing "Hello World!" (without specifying 'Console' class) +ReadKey(); diff --git a/Csharp/examples/TopLevelStatementCSharp.cs b/Csharp/examples/TopLevelStatementCSharp.cs new file mode 100644 index 00000000..03622c60 --- /dev/null +++ b/Csharp/examples/TopLevelStatementCSharp.cs @@ -0,0 +1,9 @@ +Console.WriteLine("Hello, World!"); +/*System.Console.WriteLine("Hello World!"); +can be used if you don't set up +'using System;' at top of file +"At compile time, the compiler injects top-level statements into a generated Main method, +which remains the program's entry point.*/ + +// Include this line to keep the console from closing right after printing "Hello World!" +Console.ReadKey();