A Simple C# Application (Cont.)

  1. Double click on , the Code Editor for as shown below will appear. The top of the Code Editor consists of a list of objects such as and their associated events or procedures such as .




  2. Enter the following two commands in the method :

    • In order to display the output of the program, you have to add the statement.

    • The command displays the output on the label.

    After building the project, click on the Debug menu to run the program and you will get the output as shown in the previous slide.

     using System;
     using System.Windows.Forms;
    
     namespace WindowsFormsApp2 {
       public partial class Form1 : Form {
         public Form1( ) { InitializeComponent( ); }
    
         private void Form1_Load( object sender, EventArgs e ) {
           this.Show( );
           label1.Text = "Welcome to C#!";
         }
       }
     }

    where the method InitializeComponent loads the compiled page of a component. Just leave it there.