February 26, 2017
Hot Topics:

Programming with C# - - 101

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

Preparing to Program

You should take certain steps when you're solving a problem. First, you must define the problem. If you don't know what the problem is, you can't find a solution! After you know what the problem is, you can devise a plan to fix it. When you have a plan, you can usually implement it. After the plan is implemented, you must test the results to see whether the problem is solved. This same logic can be applied to many other areas, including programming.

When creating a program in C# (or in any language), you should follow a similar sequence of steps:

  1. Determine the objective(s) of the program.
  2. Determine the methods you want to use in writing the program.
  3. Create the program to solve the problem.
  4. Run the program to see the results.

An example of an objective (see step 1) might be to write a word processor or database program. A much simpler objective is to display your name on the screen. If you don't have an objective, you won't be able to write an effective program.

The second step is to determine the method you want to use to write the program. Do you need a computer program to solve the problem? What information needs to be tracked? What formulas will be used? During this step, you should try to determine what will be needed and in what order the solution should be implemented.

As an example, assume that someone asks you to write a program to determine the area inside a circle. Step 1 is complete, because you know your objective: Determine the area inside a circle. Step 2 is to determine what you need to know to ascertain the area. In this example, assume that the user of the program will provide the radius of the circle. Knowing this, you can apply the formula r2 to obtain the answer. Now you have the pieces you need, so you can continue to steps 3 and 4, which are called the Program Development Cycle.

The Program Development Cycle

The Program Development Cycle has its own steps. In the first step, you use an editor to create a file containing your source code. In the second step, you compile the source code to create an intermediate file called either an executable file or a library file. The third step is to run the program to see whether it works as originally planned.

Creating the Source Code

Source code is a series of statements or commands that are used to instruct the computer to perform your desired tasks. As mentioned, the first step in the Program Development Cycle is to enter source code into an editor. For example, here is a line of C# source code:

System.Console.WriteLine("Hello, Mom!");

This statement instructs the computer to display the message Hello, Mom! onscreen. (For now, don't worry about how this statement works.)

Using an Editor

An editor is a program that can be used to enter and save source code. There are a number of editors that can be used with C#. Some are made specifically for C#, and others are not.

At the time this book was written, there were only a few editors created for C#; however, as time goes on, there will be many more. Microsoft has added C# capabilities to its Visual Studio product which includes Visual C#. This is the most predominant editor available. If you don't have Visual Studio .NET, however, you can still do C# programming.

Page 1 of 5

Comment and Contribute


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



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Rocket Fuel