To create a new application window in C#, we can make use of Windows Forms. Windows Forms is a graphical user interface (GUI) class library included in the .NET Framework. It provides developers with the tools to create desktop applications that have a rich user interface.
Here's an example code snippet that creates a simple application window using Windows Forms:
main.cs539 chars23 lines
In this example, we create a new class called MainForm
which inherits from Form
. We set the window's title, width, and height in the constructor. We also provide a Main
method that launches the window when the application is run.
To run the application, we call Application.Run(new MainForm())
which creates a new instance of our MainForm
class and displays it on the screen.
Note that you will also need to include the System.Windows.Forms
namespace at the top of your file to access the Form
class.
gistlibby LogSnag