In this chapter, you
You also saw what C# actually is and how it
In this chapter, you learned:
What the .NET Framework is, why it was created, and what makes it such an attractive environment to program in
What C# is and what makes it an idea tool to program in the .NET Framework
What you need to develop .NET applications effectively, namely a development environment such as Visual Studio 2005
Now that you've spent some time learning what C# is and how it fits into the .NET Framework, it's time to get your hands dirty and write some code. You use Visual Studio 2005 (VS) throughout this book, so the first thing to do is to have a look at some of the basics of this development environment. VS is an
Once you've had a look at VS, you put together two simple applications. You don't need to worry too much about the code in these for now, you just
The first application you create is a simple
. Console applications are those that don't make use of the graphical Windows environment, so you won't have to worry about
The second application is a Windows Forms application . The look and feel of this will be very familiar to Windows users, and (surprisingly) the application doesn't require much more effort to create. However, the syntax of the code required is more complicated, even though in many cases you don't actually have to worry about details.
You use both types of application over the
So, without further ado, it's time to get started!
When VS is first loaded, it immediately
If this is the first time you have run VS, you will be presented with a list of preferences intended for users with experience of previous releases of this development environment. The choice you make here affects a number of things, such as the layout of windows, the way that console windows run, and so on. For this reason you should choose Visual C# Developer as shown in Figure 2-1,
If this isn't the first time that you've run VS but you chose a different option the first time, don't panic. In order to reset the settings to Visual C# Developer you simply have to import them. To do this, Click Import and Export Settings... on the Tools menu and select the Reset all settings option as shown in Figure 2-2.
Finally, click Finish to apply the settings.
As is evident from the above, the VS environment layout is completely customizable, but again the default is fine for you. With C# developer settings, it is arranged as shown in Figure 2-4.
The main window, which will contain a helpful
by default when VS is started, is the one where all your code will be displayed. This window can contain many documents, each indicated by a tab, so that you can switch between several files with ease by clicking on their filenames. It also has other functions: it can display graphical
Above the main window, you have toolbars and the VS menu. There are several different
Here are brief descriptions of each of the main features of VS that you will use the most:
The Toolbox toolbar pops up when the mouse moves over it and provides access to, among other things, the user interface building blocks for Windows applications. Another tab, Server Explorer, can also appear here (it is selectable via the View Server Explorer menu option) and includes various additional capabilities, such as providing access to data sources, server settings, services, and so on.
The Solution Explorer window displays information about the currently loaded solution . A solution is VS terminology for one or more projects along with their configuration. The Solution Explorer window displays various views of the projects in a solution, such as what files they contain and what is contained in those files.
Just below the Solution Explorer window you can display a Properties window, not shown in Figure 2-4. You will see what this looks like shortly, since it only appears when you are working on a project (you can also toggle its display using the View Properties Window menu option). This window allows a more detailed view of the contents of a project, allowing you to perform additional configuration of individual elements. For example, you can use this window to change the appearance of a button in a Windows form.
Also not shown in the screenshot is another extremely important window: the Error List window. This window, which you can display using the
menu option, displays error, warning, and other information
This may seem like a lot to take in, but don't worry, it doesn't take long to get used to. You start by building the first of your example projects, which involves many of the VS elements described above.
There are many other windows, both informational and functional, that VS is capable of displaying. Many of these can share screen space with the windows mentioned here, allowing you to switch between them using tabs. You will see many of these windows being used later in the book, and you'll probably discover more yourself when you explore the VS environment in more detail.