C Sharp

Running the Application

Now that you've built the "Hello, World" application, let's run it to make sure that your .NET runtime environment is set up correctly. All demos in this tutorial will be "console applications," meaning that we're sticking to C# and not doing anything specific to Windows development. As a result, you can run these demos from the command line or from your editor if it supports running command-line applications.

If you're using the command-line option, open a command window now and type HelloWorld at the command prompt where you built the application. The output should be similar to this: -

d:\>HelloWorld
Hello, World

If, on the other hand, you're attempting to run the application from an editor and either you do not see anything or a command prompt pops up, runs the application, and disappears quickly, alter your code as follows: -

class HelloWorld
{
    public static void Main()
    {
        System.Console.WriteLine("Hello, World");
        String str = System.Console.ReadLine();
    }
}

The call to System.Console.ReadLine will cause the application to pause until you've pressed the Enter key, thereby giving you the opportunity to see that the application has printed what you were expecting. From here on, the demos in this tutorial will not contain this line of code. If you're using an editor to run these demos, you'll need to remember to insert this line before the end of each application.