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;
これが true の場合、コンソールは接続されていません。たとえば、以下はこれに対して適切に機能します。
public static bool IsConsoleApplication { get { return Console.In != StreamReader.Null; } }