Free Programming E-Books
Free download ebooks on computer and programming

Free ebook "Beginning Visual C#" Sample Chapter

Beginning Visual C#
Free download Chapter 1: Introducing C#
Download chapter

With Beginning Visual C#, you will learn how to use Visual C# from first principles. Visual C# is an object-oriented programming language designed specifically for programming Microsoft's new platform, the .NET Framework. You'll quickly and easily learn how to write Visual C# code and create your own applications - for both Windows and the Web.

< < prev next > >

Introducing C#

Welcome to the first chapter of the first section of this book. Over the course of this section we'll be taking a look at the basic knowledge required to get up and running. In this first chapter we'll be looking at an overview of C# and the .NET Framework, and we'll consider what these technologies are, the motivation behind using them, and how they relate to each other.

We'll start with a general discussion of the .NET Framework. This is a new technology, and contains many concepts that are tricky to get to grips with at first (mainly because the Framework introduces a "new way of doing things" to application development). This means that the discussion will, by necessity, cover many new concepts in a short space of time. However, a quick look at the basics is essential to understand how to program in C#, so this is a necessary evil. Later on in the book we'll revisit many of the topics covered here in more detail.

After this discussion, we'll move on to a simple description of C# itself, including its origins and similarities to C++.

Finally, we'll look at the main tool that will be used throughout this book: Visual Studio .NET (VS).

What is the .NET Framework?

The .NET Framework is a new and revolutionary platform created by Microsoft for developing applications. The most interesting thing about this statement is how vague I've been - but there are good reasons for this. For a start, note that I didn't say "developing applications on the Windows operating system".

Although the first release of the .NET Framework runs on the Windows operating system, future plans include versions that will work on others, such as FreeBSD, Linux, Macintosh, and even personal digital assistant (PDA) class devices. One of the key motivational forces behind this technology is its intention as a means of integrating disparate operating systems.

In addition, the definition of the .NET Framework given above includes no restriction on the type of applications that are possible. This is because there is no restriction - the .NET Framework allows the creation of Windows applications, web applications, web services, and pretty much anything else you can think of.

The .NET Framework has been designed such that it can be used from any language. This includes the subject of this book, C#, as well as C++, Visual Basic, JScript, and even older languages such as COBOL. In order for this to work, .NET-specific versions of these languages have also appeared: Managed C++, Visual Basic .NET, JScript .NET, J#, and so on - and more are being released all the time. Not only do all of these have access to the .NET Framework, they can also communicate with each other. It is perfectly possible for C# developers to make use of code written by Visual Basic .NET programmers, and vice versa.

All of this provides a hitherto unthinkable level of versatility, and is part of what makes using the .NET Framework such an attractive prospect.

What's in the .NET Framework?

The .NET Framework consists primarily of a gigantic library of code that we use from our client languages (such as C#) using object-oriented programming (OOP) techniques. This library is categorized into different modules - we use portions of it depending on the results we want to achieve. For example, one module contains the building blocks for Windows applications, another for network programming, and another for web development. Some modules are divided into more specific submodules, such as a module for building web services within the module for web development.

The intention here is that different operating systems may support some or all of these modules, depending on their characteristics. A PDA, for example, would include support for all the core .NET functionality, but is unlikely to require some of the more esoteric modules.

Part of the .NET Framework library defines some basic types. A type is a representation of data, and specifying some of the most fundamental of these (such as "a 32-bit signed integer") facilitates interoperability between languages using the .NET Framework. This is called the Common Type System (CTS). As well as supplying this library, the framework also includes the .NET Common Language Runtime (CLR), which is responsible for maintaining the execution of all applications developed using the .NET library.