winform运行时如何接受参数?(示例)

时间:2022-04-23
本文章向大家介绍winform运行时如何接受参数?(示例),主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

关键是在Main函数中处理,示例如下

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace WinFormTest

{

    static class Program

    {

        /// <summary>

        /// 应用程序的主入口点。

        /// </summary>

        [STAThread]

        static void Main(string[] args)

        {

            foreach (string p in args)

            {

                MessageBox.Show("p=" + p);

            }

            Application.EnableVisualStyles();

            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new Form1());

        }

    }

}