How to: Build a C# Application in 60 Seconds

It only takes a minute to create a C# application. Follow these steps and in a matter of seconds you will have created a program that opens a window and reacts to a button press.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To create a C# application in 60 seconds

  1. On the File menu, click New Project.

  2. Ensure the Windows Application template is selected, and in the Name field, type "MyProject". Click OK to create the project.

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

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

  4. Click Label, and then drag the label control to the middle of your form.

  5. From the Toolbox, drag a button onto the form, near the label.

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

  7. Change the method so it reads

    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. Of course, this program is not very useful, but it does demonstrate the basic steps that you'll take in writing any C# application. If you're ready to start writing some real code, see How to: Create a New Visual C# Express Application.

See Also

Concepts

C# and the .NET Framework

Visual C# Express Features

Reference

C# Compared to Other Languages

Other Resources

Visual C# Express

Getting Started with Visual C# Express