Home > Blockchain >  Do I need the "main file" to code on c# when working with Windows Forms Application
Do I need the "main file" to code on c# when working with Windows Forms Application

Time:09-15

i recently switched from console application to windows form application in C# and i was wondering, if I work with buttons and etc. do i really need to work with the main file(The file where the void main is and the 2 lines of code with

 ApplicationConfiguration.Initialize();
 Application.Run(new Form1());

) anymore and if not how can i check if a button for example is pressed in the main file? Im wondering because the buttons and etc are private and cant be called outside the form.cs. I hope i could describe it good enough.

The file is pointing to the "main file"

CodePudding user response:

You do not need to use main file. you can write code on Form1_load event. When you windows application starts, the main function will be executed and it will load Form1. You can put your buttons on Form1 and also write code on Button_Click events.

  •  Tags:  
  • c#
  • Related