From 973ce74667892814355602505848a7ca046dd6ec Mon Sep 17 00:00:00 2001 From: wuKa Date: Wed, 21 May 2025 00:37:07 +0330 Subject: [PATCH 1/2] Add: Top-Level Statement for C# examples --- Csharp/examples/TopLevelStatementCSharp.cs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Csharp/examples/TopLevelStatementCSharp.cs 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(); From 49322643a9641a2b63b49db4517bd8711449619e Mon Sep 17 00:00:00 2001 From: wuKa Date: Wed, 21 May 2025 00:41:48 +0330 Subject: [PATCH 2/2] Add: Static Using C# example --- Csharp/examples/StaticUsingCSharp.cs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 Csharp/examples/StaticUsingCSharp.cs 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();