Passing Parameters to an Application in C#
There are no special problems with passing parameters to an application at startup in C#, it's done quite simply like this:
static void Main( string[] args)
{
if (args.Length == 0)
{ MessageBox.Show("Нет параметров"); }
else
{ MessageBox.Show("1"); }
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
The only problem is that in C# within a project, there may not be one such Main and to make it clear which one should be passed parameters, you need to specify an object in: Project > Properties > Application > Startup Object.
That's all!
Comments (0)
No comments yet.