O'Reilly logo

Learning C# 2005, 2nd Edition by Brian MacDonald, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Development Environment

The Visual Studio 2005 Integrated Development Environment (IDE) provides enormous advantages to the C# programmer. This book tacitly assumes that you’ll use Visual Studio 2005 for your work. However, the discussion focuses more on the language and the platform than on the tools.

Nonetheless, Chapter 2 provides an introduction to the IDE in some detail. Chapter 9 returns to the IDE to examine the debugger, which will help you find and correct problems in your code.

You can use the C# language to develop four types of applications:

  • Console applications, which display no graphics

  • Windows applications, which use the standard Windows interface

  • Web applications, which can be accessed with a browser

  • Web services, which can be accessed using standard Internet protocols and which provide services such as current stock quotes, ISBN to title conversions, etc., that can be used by other applications

This book will focus primarily on the basics of the C# language, using simple console applications for most of the examples, to illustrate language fundamentals. The last two chapters will show you how to use C# within the context of building Windows and web applications, respectively.

The .NET platform is web-centric. The C# language was developed to allow .NET programmers to create very large, powerful, high-quality web applications quickly and easily. The .NET technology for creating web applications and web services is called ASP.NET.

Typically, you’ll create an ASP.NET application when you want your program to be available to end users on any platform (e.g., Windows , Mac, Unix). By serving your application over the Web, end users can access your program with any browser.

When you want the richness and power of a native application running directly on the Windows platform, you will create a desktop Windows application. The .NET tools for building Windows applications are called Windows Forms.

However, if you don’t need a Graphical User Interface (GUI) and just want to write a simple application that writes to a console window (i.e., what we used to call a DOS box), you might consider creating a console application. This book makes extensive use of console applications to illustrate the basics of the C# language.

Console applications

A console application runs in a console window, as shown in Figure 1-1. A console window (or DOS box) provides simple text-based output. Console applications are very helpful when learning a language because they strip away the distraction of the Graphical User Interface. Rather than spending your time creating complex windowing applications, you can focus on the details of the language constructs, such as how you create classes and methods, how you branch based on runtime conditions, and how you loop. All these topics will be covered in detail in later chapters.

A console application

Figure 1-1. A console application

Windows applications

A Windows application runs on a PC’s desktop. You are already familiar with Windows applications such as Microsoft Word or Excel. Windows applications are much more complex than console applications and can take advantage of the full suite of menus, controls, and other widgets you’ve come to expect in a modern desktop application. Figure 1-2 shows the output of a simple Windows application.

ASP.NET applications

An ASP.NET application runs on a web server and delivers its functionality through a browser, typically over the Web. ASP.NET technology facilitates developing web applications quickly and easily. Figure 1-3 shows a message from a simple ASP.NET application.

A Windows application

Figure 1-2. A Windows application

An ASP.NET application

Figure 1-3. An ASP.NET application

Although most commercial applications will be either Windows or ASP.NET programs, console applications have a tremendous advantage in a C# primer. Windows and ASP.NET applications bring a lot more overhead; there is great complexity in managing the window and all the events associated with the window. (Events are covered in Chapter 17.) Console applications keep things simple—allowing you to focus on the features of the language.


This book does not go into all the myriad details of building robust Windows and ASP.NET applications. For complete coverage of these topics, please see Programming ASP.NET and Programming .NET Windows Applications, both by Jesse Liberty and Dan Hurwitz (O’Reilly).

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required