Chapter 3. C# Language Foundations

The best way to get started in a new programming language is to create a simple program and then examine the various parts that compose it. With this principle in mind, you'll create a simple C# program — first using Visual Studio 2008 and then using a plain text editor.

In this chapter you build and run the HelloWorld application, using Visual Studio 2008 as well as using the command line. After that, you tackle the syntax of the C# language and all the important topics, such as:

  • C# keywords

  • Variables

  • Constants

  • Comments

  • XML documentation

  • Data types

  • Flow control

  • Loops

  • Operators

  • Preprocessor directives

Using Visual Studio 2008

The easiest way to create your first C# program is to use Visual Studio 2008.

  1. Launch Visual Studio 2008.

  2. Create a new Console Application project by selecting File

    Editions of Visual Studio 2008
  3. Expand the Visual C# item on the left of the dialog, and select Windows. Then, select the Console Application template on the right (see Figure 3-1). Name the project HelloWorld.

    Figure 3.1. Figure 3-1

  4. Click OK. ...

Get C# 2008 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.