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 サービスで実行されているかどうかを判断する方法は?
コンソール固有ではありませんが(つまり、winformsアプリとして実行している場合もtrueが返されます)、私は次のものを使用しました
if (Environment.UserInteractive) { Console.WriteLine("Hi I'm being ran as a console app"); }