You are on page 1of 2

Chapter 1: Programming with Visual Studio 2010

In This Chapter
✓ Performing common tasks in the Code Editor ✓ Organizing code in C# and Visual Basic ✓ Getting started with the basics of C# and Visual Basic


o you ever get the feeling that sometimes you’re not alone? If you’ve

ever written a program with one of the Visual Studio Code Editors, you know what I mean. Writing code in Visual Studio is like having a word processor that knows what you want to say next. When you start to type code in Visual Studio, helpers appear magically out of nowhere. Like the host at your favorite restaurant, they share with you a list of today’s specials: “Might I suggest an Integer, or how about a DataSet, sir?” Even if you have no clue about all the choices that Visual Studio offers in the convenient pop-up list, just hover your mouse over one of them, and a description appears. Like a museum tour guide, Visual Studio shares with you the intimate details of the programming artifacts you’re inspecting. This chapter shows you some of the magical helpers and guides that Visual Studio uses to help you write better code. You also get a quick overview of how to write programs using two popular .NET languages: C# and Visual Basic.

Using the Code Editor

Although Visual Studio provides a great number of visual designers that allow you to generate code by dragging and dropping controls and components onto visual designers, at some point, you have to write code. Visual Studio really helps you write code by providing you with many editors for editing all kinds of files. The Source Code Editor is especially feature rich, offering a number of productivity boosting features.


Using the Code Editor

Here are some of the ways to open source code files in the Code Editor:  Double-click a source code file in Solution Explorer.  Press F7 while viewing a form in the Windows or Web Forms designers.  Add a new source code file via the Add New Items window. The Code Editor is more than just a plain text editor like Notepad. You can use the Code Editor to do many things, such as  Enter code in the main Code Pane area.  Set breakpoints in the gray Indicator Margin along the left of the editor.  Select lines of code by clicking the space between the Code Pane and the Indicator Margin. You can optionally display line numbers in the Selection Margin.  Collapse code by using the outline lines along the left margin of the Code Editor.  Jump to code via the Navigation bar along the top of the Code Editor. Figure 1-1 shows an example of the Code Editor.
Figure 1-1: Use the Code Editor to write source

code. .