If I want to have multiple forms in an appication, can I do it with only one main? I am working with Visual Studio C# (Windows Application).
Thank you.
If I want to have multiple forms in an appication, can I do it with only one main? I am working with Visual Studio C# (Windows Application).
Thank you.
Sure. There is nothing preventing you from having multiple Form
instances in a .Net application with only a single thread / main method.
var f1 = new Form();
f1.Show();
var f2 = new Form();
f2.Show();
Depending on how you want these forms to be related though there are some subtle changes you may want to make to the startup code. Can you give us a bit more information on what you're trying to achieve?
They're right, but if you want to edit the form in the designer first use Project -> Add Windows Form and select a name for the form.
This will add another form to the project and let you can open and edit it in the designer.
var f1 = new Form(); here var is variant datatype in .NET 3.5 which basically object type that can store any objects in it.