要加载什么库以停止键入控制台。 ... 每次

What library to load to stop typing Console. ... every time

每次都写出 Console.ReadConsole.Write 一直让我对这个项目感到厌烦。我知道有一个库可以加载以取出 Console 部分,这样我就可以输入 ReadLine().

有人知道这是什么吗?我忘记了。

谢谢!

这是 C# 6.0 中引入的名为 "static using directive" 的功能:

using static System.Console;

MSDN static using directive:

To allow you to access static members of a type without having to qualify the access with the type name: using static System.Math;

有关 C# 6.0 功能的更多信息,请参阅:How C# 6.0 Simplifies, Clarifies and Condenses Your Code

不是库,从 C# 6 开始你可以使用 "static using directive":

using static System.Console;

...

WriteLine("Test"); // Console. is assumed

以下是包含更多信息的一些链接:

请注意,您必须在 using 指令中给出类型的完整限定名称,因此 using static Console 是不够的。