C# 24-Hour Trainer. Stephens Rod

Чтение книги онлайн.

Читать онлайн книгу C# 24-Hour Trainer - Stephens Rod страница 5

C# 24-Hour Trainer - Stephens Rod

Скачать книгу

working in teams. This includes tools that you don't need right now and that can provide extra opportunities for confusion, so skip this version. (If you don't think things are confusing enough, e-mail me and I'll suggest some more confusing topics for you to study.)

      The Community Edition includes tools to get started building any of these kinds of applications, so it's a good choice. You may never use it to build websites or iOS applications, but having those abilities installed won't hurt you.

      The Express Editions are only intended to get you started, but they're seriously powerful so you probably won't need anything else for quite a while. I've been happily using Express Editions for about two decades.

      If you think you need some other version of Visual Studio (for example, you're working on a big project and you need test management, source code control, and other team programming tools), go to msdn.microsoft.com/vcsharp and install the version that's right for you.

      All of these are big installations (5 or 6 GB), so they could take a while. While a constant supply of cookies, caffeine, and conversation will help you pass the time more quickly, the other customers won't thank you if you hammer the Starbucks Wi-Fi for 12 straight hours. Be sure you have a reasonably fast connection before you start.

      Talkin' 'Bout My Generation

      Developers talk about different generations of programming languages ranging from the very primitive to the remarkably advanced. In a nutshell, the different generations of languages are:

      ● 1GL– Machine language. This is a series of 0s and 1s that the machine can understand directly. Here's a sample: 01001010 11010100 10101011 10001000. Pretty hard to read, isn't it?

      ● 2GL– Assembly language. This is a collection of mnemonic codes that represent machine language instructions. It is slightly more readable but provides no higher-level structure for performing complex tasks. Here's a sample: brfalse.s IL_0028 leave.s IL_007a ldloc.0 ldloc.1. This may be easier to read than binary, but it still looks like gibberish to me.

      ● 3GL– A higher-level language such as FORTRAN or BASIC. These provide additional structure (such as looping and subroutines) that makes building complex programs easier. Here's a sample: num_players = num_players + 1. Finally something I can read and almost understand!

      ● 4GL– An even higher-level language or a development environment that helps build programs, typically in a specific problem domain.

      ● 5GL– A language where you specify goals and constraints and the language figures out how to satisfy them. For example, the database Structured Query Language (SQL) allows you to use statements like SELECT FirstName FROM Employees. You don't need to tell the database how to get the names; it figures that out for you.

      Visual Studio provides code snippets that let you copy standard chunks of code into your program, IntelliSense that helps you select and use functions and other pieces of code, refactoring tools that help you rearrange and restructure your code, and much more. That makes Visual C# a 4GL. (Or perhaps a 3.5GL depending on how high your standards are.)

      Configuring the IDE

When you first run Visual Studio, the dialog shown in Figure 1.1 appears to let you configure the IDE. (You may also see a few other dialogs before that point asking you to log in to your Microsoft profile. You can create one if you don't already have one.)

Figure 1.1

      The dialog lets you pick settings for general development, Visual Basic, Visual C#, and so forth. Because you're going to be focusing on C# development, select that option.

      NOTE

      These settings determine such things as what keystrokes activate certain development features. You can certainly write C# programs with the Visual C++ settings, but we may as well use the same playbook, so when I say, “Press F5,” the IDE starts your program instead of displays a code window or whatever Visual C++ thinks F5 should do.

      The dialog also lets you pick a color scheme. Pick the one you think you'll like best (admittedly without getting to try them out) and click Start Visual Studio. (Then be ready to wait again because the initial configuration can take a while.)

      If you ever want to switch to different settings (for example, if you initially picked the Dark colors but then discovered that they give you a headache), you can always change them later.

      To change the settings, open the Tools menu and select Import and Export Settings to display the Import and Export Settings Wizard. You can use this tool to save your current settings, reload previously saved settings, or restore the settings to their default values.

      To reset the settings, select the Reset All Settings option on the wizard's first page and click Next.

On the next page, indicate whether you want to save your current settings. When you've made your choice, click Next to display the page shown in Figure 1.2. Select the Visual C# choice and click Finish.

Figure 1.2

      Then sit back and wait. Or better still, go get something to drink because this could take a while. Visual Studio has a lot of settings to reset, and it could take several minutes depending on how fast your computer is. (And how busy your computer is playing YouTube videos.)

      Building Your First Program

      Now that you've installed C#, you're ready to build your first program. Launch Visual Studio by double-clicking its desktop icon, selecting it from the system's Start menu, finding it with the Windows Search tool, or doing whatever you do to run programs on your version of Windows.

When it starts, Visual Studio should look more or less like Figure 1.3. You can use the links in the center pane to get more information about Visual Studio,NET, Azure, and whatever else Microsoft thinks is important today.

Figure 1.3

      You can use the links in the left pane to create a new project or open an existing project. You can also create a new project by opening the File menu, expanding the New submenu, and selecting Project. Or if you're in a hurry to create your first project, just press Ctrl+Shift+N.

      NOTE

      Often you have several ways to do something in Visual Studio. You may be able to use a menu command, keyboard shortcut, or toolbar button to do the same thing. Usually I'll just mention one or two ways to do something, such as creating a new project, but you'll probably discover other ways, too.

All of those methods display the New Project dialog shown in

Скачать книгу