How to Compile and Run a C# Program

On October 7, 2009, in .NET, by Allen Ryan

To compile a C# program using Visual Studio .NET

  1. Run Visual Studio .NET.
  2. Click File > Open, and then click Project.
  3. Open the install folder\Democode\Converter.sln project.
  4. Click Build > Build Solution.

To run the C# program from Visual Studio

  1. Click Debug > click Start Without Debugging.
  2. A console window will run
  3. Press any key to close the program.
Share
Tagged with:
 

Using Visual Studio to Create a C# Program

On September 25, 2009, in .NET, by Allen Ryan

In this demonstration, you will create a C# console application by using Visual Studio .NET.

To create a C# application

  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. In the New Project dialog box, provide the information shown in the following table, and then click OK.
    csr
  4. When the project has been generated, point out and discuss the following features of Visual Studio:
    • The Solution Explorer window
      1. Close the Class1.cs code window.
      2. Change the name of Class1.cs to Hello.cs.
      3. Double-click Hello.cs to redisplay the code window.
    • The Properties window
    • The toolbars
    • The View menu
    • The Build menu
    • The Debug menu
    • The Help menu
  5. Using the code window displaying Hello.cs, point out and discuss the
    following:

    • The Hello namespace

      Mention that namespaces will be discussed later. You could delete this line and the corresponding braces, but leave them intact for now.

      • The using directive
      • The XML comments

        Use this section to provide a brief description of the program. Comments
        will be covered more fully later.

      • The class definition

        The default name for the class is Class1. Change it to Demonstrator.

      • The Main method

        Insert the following code:

        Console.WriteLine(“Hello, World”);

      • Microsoft IntelliSense®
  6. On the File menu, click Save All.
  7. Exit Visual Studio.
Share
Tagged with: