WPF / Console Hybrid Application

后端 未结 4 1889
长发绾君心
长发绾君心 2021-02-13 01:27

I writing an application what can either be run on the command line, or with a WPF UI.

[STAThread]
static void Main(string[] args)
{
    // Does magic parse args         


        
4条回答
  •  时光说笑
    2021-02-13 02:09

    Your best bet would be to abstract out the code that actually does the work to a separate class library that has no UI and then create two applications one Console, the other WPF that call this.

    A console application and an WPF application have entirely different application models so you can't reuse the same code in both applications.

    Having a separate class library allows you do other things like use it in other applications such as a web site or client/server architecture.

提交回复
热议问题