C# practice notes 1. Language_ Use of grammar

Time:2021-8-19

1、 Using static
1. The new syntax of c#6 using static can simplify the prefix:
Example:

1 using static System.Console; // 1. Using static
 2 
 3 namespace test
 4 {
 5     internal class Program
 6     {
 7         private static void Main(string[] args)
 8         {
 9             WriteLine("test"); // 2. Omit console. It's just a syntax sugar. Console.WriteLine("test");
10         }
11     }
12 }

2. Only its static methods can be used
At present, I use instance in singleton mode, omitting the prefix of class name, which is a bit similar to using instance in C + + macro definition.

Recommended Today

Lua language novice simple tutorial

1、 Foreword Lua is a lightweight and compact scripting language, which is written in standard C language and open in the form of source code. Its design purpose is to be embedded in the application, so as to provide flexible expansion and customization functions for the application. Lua can be applied in game development, independent […]