开发者

C#: Check if windows form

开发者 https://www.devze.com 2022-12-17 03:35 出处:网络
How can I check at runtime whether a C# application is a Windows application or a console application?

How can I check at runtime whether a C# application is a Windows application or a console application?

I want to write a generic output library (output to textbox or console when console app).

For that reason开发者_开发知识库, if I could check whether it is a asp application would be useful, too.


I think you may be attacking the problem in the wrong way. Without knowing more about what you are doing here is what I'd suggest:

Create an interface called something like IOutputWriter with a Write(...) method. Then create an implementation for each environment (ConsoleOutputWriter, TextboxOutputWriter, etc...). Each environment can use the appropriate implementation since they know what type of app they are.

0

精彩评论

暂无评论...
验证码 换一张
取 消