Lesson 1.4 – Day 01 Visual Studio IDE Overview

C# Course for Absolute Beginners – Lesson 1.4
Next Lesson

Introduction

Each day you should understand a little more about the Visual Studio IDE, or Interactive Development Environment, that is used in Visual C# Express Edition. In this lab you’ll learn several new things about the IDE. In a previous lab we already noted several of the major areas- the Solution Explorer, and the Start Page that opens up whenever we initially load Visual C# Express Edition. We also learned a little about the Toolbar and the Menu. In this lab we want to discuss a few additional features that should help you better understand the code as you continue to learn C#.

 

Step 1: Using IntelliSense as a Programming Aide

Step 1: Using IntelliSense as a Programming Aide

IntelliSense is a very useful feature in the VIsual Studio IDE. To see an example:

Delete the Console.Readline; line of code
Re-type the first two or three letters.

Notice that several things happen. Underneath where you type, there’s this a that pops up with a highlighted word. As you type, a little explanation pops over a little tool tip off to the right-hand side. This little window that appears underneath what you type is called IntelliSense. IntelliSense helps us in the following ways:

- It shows the available options
- It ensures correct spelling
- If you press the "period" key on your keyboard, it will type out the word for you.

So you can use IntelliSense to save a lot of keystrokes, which will greatly improve your efficiency. You only have to type three or four letters and then use the arrow keys on the right-hand side of your keyboard to find the class or the method that you want to use. Then select the next delimiter, and you’ve saved a lot of time.

IntelliSense is also contextually sensitive to what you’re working on right now:

-Delete Console.ReadLine; again (assuming you retyped it in the above example)
-Type the first two or three letters of: ReadLine;

Notice that IntelliSense does not show ReadLine as an option. This is because IntelliSense knows that you can’t just call a method without first calling its class. It’s not in the scope (we’ll talk about scope later). If you want to use IntelliSense to access the ReadLine method, you first need to type the object within the appropriate NameSpace that we’ve defined at the top – the System namespace.

- Type the first two letters of Console and press the "enter" key on your keyboard.
- Type the first two letters of ReadLine and press the "enter" key on your keyboard.

Notice how IntelliSense did the rest of the work for you!

 

Step 2: Using Tool Tips to Discover Additional Information

Step 2: Using Tool Tips to Discover Additional Information

Tool Tips work in conjunction with IntelliSense, but you can use the feature anywhere.

If you hover your mouse over our string literal "Hello World" you can read: class System.String represents text as a series of Unicode characters.
If you hover over WriteLine you’ll see the method definition for WriteLine – void. We’ll discuss void later. You’ll also see that it’s a string value, and there are 18 overloads. Finally, you’ll see the following: Writes the specified string value followed by the current line terminator to the standard output stream.

What that means isn’t very important right now, but it demonstrates a good point: tooltips aren’t always extremely helpful, at least when you first begin programming. Unfortunately there isn’t another set of Tool Tips for beginners, but later Tool Tips will become much more valuable.

Tool Tips can be especially helpful when you’re looking at other people’s code. We’ll revisit this later when we discuss navigating through other people’s code or even your own code to find what you’re looking for.

 

Step 3: Locating Your Place with Line and Column

Step 3: Locating Your Place with Line and Column

There are several important elements at the bottom of the Visual Studio IDE window.

(1) Ready – This tells us that we can work with the IDE now; that it’s not busy doing something.

(2) Ln tells us what line number we’re on. If you use the arrow key on your keyboard to move up or down, you’ll see the line number change.

(3) Col tells us what column number we’re on. If you use the arrow keys on your keyboard to move left or right, you’ll see the column number change.

(4) INS is the insert mode. This can be changed with your keyboard options, depending on what keyboard options you’ve selected.

These tools are very useful in determining your location. Imagine that the lead programmer on a project says, "We’re not going past line column 70, just in case we have developers that have smaller screens. Format all of your code so that it fits within the first seventy columns." These tools will help you stay within the lead programmer’s requirements.

 

Step 4: Correcting Errors Using Line Numbers and the Error List

Step 4: Correcting Errors Using Line Numbers and the Error List

Line numbers also help identify and correct errors in your code. If you have an error, the Error List will display both the line number as well as the column number.

In addition, throughout this series of labs we may ask you to reference specific lines of code. Right now our code is very small, but in the future we may have hundreds of lines. If you’re asked to reference line 56, you can use these tools to quickly locate the correct code line.

 

Step 5: Customizing the Visual Studio IDE

Step 5: Customizing the Visual Studio IDE

To identify your location more quickly, you can change the features in the main area of your IDE to display line numbers. If you prefer, you can undo this option at any time.

Go to the tools menu and select options

(1) In the new window, select the the text editor portion and go to the C# option – expand that

(2) It’s possible that you may not see exactly this on your screen. To correct that, select "Show all settings" Now you should be able to select C# and see line numbers.

(3) You’ll see that there are many options with regards to how the IDE displays and behaves. One of those options are line numbers. By default, this option is deselected.

Check the checkbox and then click OK on the dialogue

 

Now in the left-hand column we see line numbers displayed.

Remember – none of these options are important to the C# Compiler, the .NET Framework Class Library, the .NET Framework Runtime, or any other components. This is purely for your reference purposes. You should use this tool often; it’s highly recommended that you take a moment turn on the line numbers in your own IDE.

 

Notice that there are other options that can be set as well. If you don’t like the default font, you can return to the tools options menu and then go to environment, then ‘fonts and colors’ and change the default size or the color of the background. Some people love to change the colors from white background to black and then change the item foreground to white, claiming it’s easier on the eyes. For the purposes of these labs we’ll keep the default colors and font sizes, but you may customize your own environment to whatever suites you best.

 

Step 6: Improving Code Readability by Collapsing and Expanding Code with Code Blocks.

Step 6: Improving Code Readability by Collapsing and Expanding Code with Code Blocks.

To the right of the line numbers you can see little minus signs in a box. These are sections of code, called code blocks. When you’re not dealing with a particular section, you can roll it up to avoid distraction.

(1) Click the negative sign to collapse a particular code block. If you hover your mouse cursor over the negative sign, you’ll see a preview of the code that will be collapsed. The code will be displayed with a light bluish-gray background.

(2) Click the positive sign to expand a particular code block.

(3) Hover your mouse cursor over the ellipses to see a snapshot of the collapsed code that’s rolled up underneath.

Again – in a simple example like this with only 17 lines of code, it’s easy to find what we’re looking for. When our code grows to hundreds (or even thousands) of lines, this tool becomes very valuable.

 

Step 7: Tracking Changes with Visual Studio IDE Visual Clues.

Step 7: Tracking Changes with Visual Studio IDE Visual Clues.

Finally, the Visual Studio IDE aides in tracking changes. The Visual Studio IDE will help you track the changes that you’ve made, and whether or not you’ve saved those changes.

Imagine the following scenario:

You’re editing a program, attempting to improve functionality and correct a bug. How can you track changes to the file, and remember if you’ve saved your changes? If your program crashes, what happens to the source code you wrote? What if you wrote dozens, or hundreds of lines of code?

To help avoid problems, the Visual Studio IDE provides visual reminders – cues to help remind you to save. You can see these in two places:

(1) The asterisk next to the filename in the tab of the current item that we’re working with, or with any of the tabs that are displayed in the main area.

(2) The yellow lines to the left of your code.

There are both green lines and yellow lines. The yellow lines mean we need save. The green lines mean that the changes have been saved. It’s a way of tracking changes.

 

Click the Save All button, and you’ll notice the following:

(1) The asterisk is removed in the filename in the tab

(2) The yellow lines turn to green.

 

Conclusion

In this lab, you’ve seen multiple ways to use the Visual Studio IDE to aide you in your coding:

- You’ve learned how to use IntelliSense to ensure correct spelling, and to speed your coding.
- You’ve learned how to use Tool Tips to learn additional information about your code
- You’ve learned how to use line and column numbering to locate code.
- You’ve learned how to customize the IDE by displaying line numbers, and how to change both font and colors.
- You’ve learned how to track changes in your code.

Each of these is very important. You’ll use these skills and tools throughout your tenure as a software developer, so it’s good to learn these at the beginning of your learning experience.

 

Next Lesson

10 Year Anniversary Sale - 30% Off - ENDING SOON!!!    Learn more ...