F
F
Frip2018-04-23 14:13:58
Windows
Frip, 2018-04-23 14:13:58

Where to register your functions when working with Windows Forms?

Hello.
While I'm starting to work with WinForms, this is why I have such a question. That's when we write actions for various buttons, methods are formed in the Form class (Form1.cs).
But if I need to write a regular method that only takes values ​​and returns something, where should we write it? In the file Form1.cs or Programm.cs (class programm, well, where is static void main());
Are there any nuances when passing data to such functions?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Ananiev, 2018-04-23
@SaNNy32

Write in Form1.cs

S
Stanislav Makarov, 2018-04-23
@Nipheris

You must write it where it belongs. Form classes and the Program class are just some of the many classes that can and should be in your program.
Your question is not directly related to Windows Forms, you need to learn the C# language and how to solve problems with it: how to use classes, how to format algorithms and data with their help, and so on. Now you are trying to solve the problem with the few tools that you understand and that you see in front of you.
However, if you need to solve an elementary task from the textbook right now and the above questions do not bother you yet, you can add a method to the form class.

B
baimkin, 2018-04-23
@baimkin

I would also like to understand how to properly structure the application code, at the moment I also write all my code in the form class, but I would like to understand where to write it correctly when creating applications in WinForms. Since the application is already getting quite large, it becomes more and more difficult to navigate the form class. I would like to see the structure of a fairly large application in the form of a screen of a solution explorer like this on an example, but 5addde7c57b71294518896.jpeg
such a screen would also give a clear answer to the Author of the question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question