关于c#:C实践笔记1语言语法的使用

2次阅读

共计 300 个字符,预计需要花费 1 分钟才能阅读完成。

一.using static
1.C#6 using static 新语法, 能够简化前缀:
例:

 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. 省去写 Console. 只是语法糖而已。Console.WriteLine("test");
10         }
11     }
12 }

2. 只能应用它的静态方法
目前我在单例模式来用 Instance, 省略类名的前缀,这有点相似应用 c ++ 的宏定义来应用实例。

正文完
 0