Questions in Windows Forms and C#

Asked

Viewed 170 times

3

I’m trying to learn C# but I have a hard time understanding the hierarchy of files and folders of Solution Explorer from Visual Studio 2013.

I can’t understand why there are two files .Cs, which is intended for the design of form and another for the code of the program itself.

Finally, someone has already gone through this difficulty in understanding the file structure and some more important information in building the code?

Another question: you can create forms in C# using the Windows Console Application do VS? I’m referring to the same way we do in Eclipse when we create visual components using raw code.

Thank you.

  • I really liked it when C# and Basic created two files for Windows Forms. The first with the design of the form, which he himself writes to us already with the right code even with the name of events, and that we do not need to edit. And the other with the methods, that we edit ourselves. I took this idea to Eclipse, there I create these two files. From my point of view, this helps in the organization of code and classes. Already writing the code on the console should be very difficult to identify errors later. I believe that should give a double job.

1 answer

8

Why are there two. Cs files that are intended one for the design of form and another for the code of the program itself

A . Cs is the source of the design you made on hand. When you have the program run, this . Design Cs will run and will place the items on the screen based on this code.

The other . Cs is the code that will be run based on the events

Another question: You can create forms in C# using the VS Windows Console Application option?

Yes, just do the code below, but it is not recommended:

using System.Windows.Forms;

[STAThread]
static void Main() 
{
    Application.EnableVisualStyles();
    Application.Run(new Form());
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.