窗体和控制台应用程序

窗体和控制台应用程序

本文介绍了窗体和控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我有窗口表单应用程序,我想同时运行窗口窗体和控制台(作为bat文件)。

I have window form application which I would like to run both window form and console (as bat file).

所以,如果参数传递我希望作为控制台运行也使用console.writeline写入控制台 

So, If argument is passed I want to run as console also write to console using console.writeline 

并且如果参数未通过则以窗口形式运行。

and If argument is not pass then run as window form.




推荐答案

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
        if (args.Length == 0)
        {
            Form1 f1 = new Form1();
            Application.Run(f1);
        }
        else
        {
            // just an example of how to get it going
            MyConsoleClass myConsole = new MyConsoleClass();
            while (true)
            {
                Console.WriteLine("Starting Console ...");
                myConsole.DoStuff(); // or whatever you're going to do here
                Console.ReadLine();
            }
        }
    }
}





这篇关于窗体和控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 19:34