This documentation is archived and is not being maintained.

Filtered Completion Lists in C#

IntelliSense removes unnecessary members from the completion list by using filters.

Visual C# filters the completion lists that appear for these items:

  • Interfaces and base classes.

  • Attributes.

  • as and is operators.

  • Catch clauses.

  • Object Initializers

  • String objects

  • Events

IntelliSense automatically removes items from the interface and base class completion lists, in both class declaration base and interface lists and constraint lists. For example, enums do not appear in the completion list for base classes, because enums cannot be used for base classes. The completion list of base classes only contains interfaces and namespaces. If you select an item in the list and then type a comma, IntelliSense removes base classes from the completion list because Visual C# does not support multiple inheritance. The same behavior occurs for constraint clauses also.

When you apply an attribute to a type, the completion list is filtered so that the list only contains those types that descend from the namespaces that contain those types, such as Attribute.

For the as operator, IntelliSense completion lists are filtered so that only reference types appear after you type as. In addition, a completion list is displayed automatically when you press the SPACEBAR after you have typed the as or is keyword.

For catch, the IntelliSense completion list only displays the relevant types. These types include those derived from Exception, types that include nested types, and types that are constrained on types that derive from Exception.

Only members that can be initialized will appear in the completion list. For example:

class Cust
    public string Name { get; set; }
    public int Age { get; set; }
class MyApp
    static void Main()
        var customer = new Cust()
            //Name and Age appear in completion list
            Name = "Sally",
            //Only Age appears in completion list
            Age = 30

The previous example first creates a class Cust with two auto-implemented properties. When we initialize the Name property, only Name and Age appear in the completion list. The completion list filters out entries that are not relevant to initializing the object. For information about object initializers, see Object and Collection Initializers (C# Programming Guide)

When you use String objects, the Visual C# completion list does not display extension methods from the IEnumerable interfaces. This is performed to hide complexity on a frequently used type.

When you type the keyword event (C# Reference), the completion list only contains delegate types.