Share via


List Members

You can display a list of valid members from a type or namespace. When a member from the list is selected, you can insert that member into your code by pressing TAB, or by typing a space or period.

IntelliSense Example

Completion and Suggestion Modes

IntelliSense provides two alternatives for IntelliSense statement completion: completion mode and suggestion mode. Use suggestion mode when classes and members are used before they are defined.

In suggestion mode, when you type in the editor and then commit the entry, the text you typed is inserted into the code. When you commit an entry in completion mode, the highlighted entry in the members list is inserted into the code.

Note

Suggestion mode helps to reduce situations where IntelliSense inserts unintended text into the editor. Statement completion was originally designed so that you would use identifiers and APIs that already exist. However, if you entered an identifier that was not in the IntelliSense members list and pressed a key that caused the highlighted entry to commit, the entry would replace the typed identifier. The issue is especially important when you use development styles, for example, test-first development, that encourage the use of classes and members before you define them.

Suggestion mode is available in Visual Basic and C#.

To toggle between completion mode and suggestion mode

  • Press CTRL+ALT+SPACEBAR.

    You can use this even when an IntelliSense window is open.

    Alternatively, on the Edit menu, point to IntelliSense, and then click Toggle Completion Mode.

In some IntelliSense scenarios, suggestion mode is used even if you do not enable it.

Completion mode

IntelliSense Completion Mode

To use IntelliSense in completion mode

  1. Start typing the name of an object. IntelliSense displays all valid members in a scrollable list. As you type, the appropriate symbol is highlighted.

    You can scroll or use the arrow keys to navigate through the list, or, if you know the first few letters of the member name, begin typing to jump to the member in the list.

  2. After the name of a class or structure, type the members access operator or scope operator, as follows:

    In Visual Basic

    • . (members access operator) for a type or object instance.

    In C#

    • . (members access operator) for a type or object instance.

    • :: (namespace alias qualifier operator)

    In C++

    • -> (pointer to member) for a pointer to an object instance.

    • :: (scope resolution operator) for a class, structure, union or namespace.

  3. To insert the highlighted member in your code, use one of the following steps:

    • Type the character that follows the member, such as opening parenthesis, comma, space, semicolon, or others, to insert the selected member, followed by the character that you have just typed. This works for any non-identifier character.

      -or-

    • To commit the entry, press TAB, or type a space, semicolon, period, or parenthesis. If no item is selected in the drop-down menu, press ENTER to insert a blank new line.

Note

Even in completion mode, you can press ESC to remove the IntelliSense window. The entry committed to the editor is then the same as the entry you typed.

Suggestion mode

IntelliSense Consume-First Mode

To use IntelliSense in suggestion mode

  1. Start typing the name of an object. As you type, the box at the top of the IntelliSense window shows the characters you typed, which are the same as the characters typed into the editor. In the members list, the appropriate symbol has a focus rectangle and is not highlighted.

  2. After the name of a class or structure, type the members access operator or scope operator (as shown earlier in this topic).

  3. To commit the entry that you typed, type a space, semicolon, period, or parenthesis. The editor then shows the symbol you typed instead of the entry from the members list. To commit the entry in the focus rectangle, press TAB.

Note

Even in suggestion mode, you can press DOWN ARROW to move to the IntelliSense members list. The appropriate symbol is then highlighted instead of having a focus rectangle, and you can press UP ARROW or DOWN ARROW to highlight symbols. The highlighted symbol is committed, just as it is in completion mode.

Note

The Generate From Usage feature lets you use classes and members before you define them. You can generate a stub for any undefined class, constructor, method, property, field, or enum that you want to use but have not yet defined. When you click an undefined identifier, a smart tag is displayed. When you click the smart tag, the appropriate options are displayed.

Mode Summary

The following table summarizes the differences between completion mode and suggestion mode.

Operation

Completion Mode

Suggestion Mode

Box at top of IntelliSense window

No box appears.

Box shows the characters you typed, which are the same as the characters typed into the editor.

As you type

Symbol is highlighted.

Symbol has a focus rectangle, and is not highlighted.

Type a space, semicolon, period, or parenthesis

Highlighted symbol is committed.

Symbol you typed is committed.

Press TAB

Highlighted symbol is committed.

Symbol in the focus rectangle is committed.

Members List

When you select an item on the Members list, but before you insert it, you get Quick Info on the item and any code comments for the item. For more information, see Quick Info and Supplying XML Code Comments.

The icon to the left represents the type of the member, such as namespace, class, function, or variable. For a list of icons, see Class View and Object Browser Icons.

To turn List Members off by default, clear Auto list members on the General property page for the desired language. For more information, see Modifying IntelliSense Options.

The Members list may have many entries. You can press PAGE UP and PAGE DOWN to move up or down in the list.

Invoking IntelliSense Manually

You can manually start the List Members feature.

To manually start the List Members feature

  • Press CTRL+J.

  • Or, on the Edit menu, click IntelliSense and then click List Members.

  • Or, on the Text Editor toolbar, click List Members.

When it is invoked on a blank line or outside a recognizable scope, the Members list displays symbols in the global namespace.

In C++

If you start List Members by using the cursor in global scope or by typing :: in any valid scope, IntelliSense populates the Members list by using global symbols, which include system API functions and C++ classes.

See Also

Other Resources

Using IntelliSense