In Visual Studio, the easiest way to get help is through IntelliSense. The second easiest way is through pressing F1. There isn't much to say about pressing F1. Simply put the cursor over an identifier and press F1. The IDE does the rest. IntelliSense is a more complicated subject.
IntelliSense is a broad category covering a range of interconnected services that the Visual Studio IDE provides for C# developers.
The List Members and Complete Word features appear automatically when you start typing in the IDE. Start a new Console application. Type Console.Wr. You will see something like the image in Figure 01.
Figure 01: IntelliSense. The text we type is on the left, the Completion List in the middle, then a gray Quick Info window on the right. Click to see full size.
After we type Console and a period, we see a list of methods that belong to the Console class. As we continue typing, one of the methods may become highlighted. At that point we can press TAB, SPACE, or ENTER to have the word inserted into our code.
This feature is simultaneously doing three things:
- It is helping us explore our code with a list of members
- It is helping us type code with the Complete Word feature
- It is providing detailed help through the QuickInfo feature.
List Members and Complete Word are so closely bound together that I think of them as two sides of one feature. The Quick Info feature often appears when I am using List Members of Complete Word, but it can be invoked at other times by pressing (Ctrl + K, Ctrl + I).
A fourth, very powerful feature is Parameter Completion. Suppose I have typed the name of a method such as WriteLine and want to discover what parameters can be passed to it. I place the cursor after the opening paranthesis in the parameter list, and type Ctrl + Shift + Space. This brings up the list of parameters. I can scroll through them with the down arrow key.
Figure 2: Viewing the 11th of 19 overloads of the WriteLine method.
The real key to using IntelliSense effectively is learning how to access it with keyboard shortcuts. You can access them all from the menu with Edit | IntelliSense, but I think the shortcuts are more useful:
- List Members (Ctrl + J) or (Ctrl+Space). Also Complete Word.
- Quick Info (Ctrl+K, Ctrl+I)
- Parameter Info (Ctrl + Shift + Space)
- If you have a bunch of errors, press F8 to go to the next one.
- Generate from Usage
Completion Mode vs Suggestion Mode: (Toggle with Ctrl-Alt-Space). In completion mode pression TAB, SPACE, or ENTER. In Suggestion mode, only TAB works.