Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Creating Your First C# Application 

It only takes a minute to create a C# application. Follow these steps to create a program that opens a window and reacts to a button press.

Procedures

To create a C# application

  1. On the File menu, point to New, and then click Project.

  2. Ensure the Windows Application template is selected, in the Name field, type MyProject, and click OK.

    You will see a Windows Form in the Windows Forms designer. This is the user interface for your application.

  3. On the View menu, click Toolbox to make the list of controls visible.

  4. Expand the Common Controls list, and drag the Label control to your form.

  5. Also from the Toolbox Common Controls list, drag a button onto the form, near the label.

  6. Double-click the new button to open the Code Editor. Visual C# has inserted a method called button1_Click that is executed when the button is clicked.

  7. Change the method to look like this:

    private void button1_Click(object sender, EventArgs e)
    {
        label1.Text = "Hello, World!";
    }
    
  8. Press F5 to compile and run your application.

    When you click the button, a text message is displayed. Congratulations! You've just written your first C# application.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft