September 1, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Programming with C# - - 101

  • November 19, 2001
  • By Bradley L. Jones
  • Send Email »
  • More Articles »

Completing the Development Cycle

After your program is a compiled IL file, you can run it by entering its name at the command-line prompt or just as you would run any other program.

If you run the program and receive results different from what you thought you would, you need to go back to the first step of the development process. You must identify what caused the problem and correct it in the source code. When you make a change to the source code, you need to recompile the program to create a corrected version of the executable file. You keep following this cycle until you get the program to execute exactly as you intended.

Figure 1.2 shows the program development steps. For all but the simplest programs, you might go through this sequence many times before finishing your program. Even the most experienced programmers can't sit down and write a complete, error-free program in just one step! Because you'll be running through the edit-compile-test cycle many times, it's important to become familiar with your tools: the editor, compiler, and runtime environment.

Figure 1.2.The steps involved in C# program development.

Your First C# Program

You're probably eager to try your first program in C#. To help you become familiar with your compiler, Listing 1.1 contains a quick program for you to work through. You might not understand everything at this point, but you should get a feel for the process of writing, compiling, and running a real C# program.

This demonstration uses a program named hello.cs, which does nothing more than display the words Hello, World! On the screen. This program is the traditional program used to introduce people to programming. It is also a good one for you to use to learn. The source code for hello.cs is in Listing 1.1. When you type this listing, don't include the line numbers on the left or the colons.

Listing 1.1. hello.cs

1:  class Hello2:  {3:     static void Main() 4:     {5:        System.Console.WriteLine("Hello, World!");6:     }7:  }

Be sure that you have installed your compiler as specified in the installation instructions provided with the software. When your compiler and editor are ready, follow the steps in the next section to enter, compile, and execute hello.cs.

In order to create a C# program you will need a C# compiler. Microsoft includes a C# compiler with its .NET Framework. The .NET Framework can be downloaded from the Microsoft site (http://www.microsoft.com/net/downloads.asp).





Page 4 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel