Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法从应用程序本身检查程序是处于控制台模式还是 Windows 模式?我知道 Read 和 ReadLine 可以以某种方式检测到这一点,但是如何呢?
你应该可以检查一下Console.In == StreamReader.Null;
Console.In == StreamReader.Null;
如果这是真的,则没有附加控制台。例如,以下内容适用于此:
public static bool IsConsoleApplication { get { return Console.In != StreamReader.Null; } }