Master IntelliSense #8
Chapter 2, Master the Editor
|
43
HACK
located inside of the method parameters parenthesis, pressing Ctrl-Shift-
Space (Edit.ParameterInfo) will display the parameter information pop up.
Figure 2-9 shows this pop up.
Quick Info
When you move your mouse over a method or variable, you will see a small
tool tip pop up that contains information about that method or variable.
This is commonly called Quick Info. If you are navigating by keyboard, you
can also get this small pop up by pressing Ctrl-K and then Ctrl-I (Edit.
QuickInfo). Using this shortcut is also the only way to bring up this infor-
mational pop up during debug, since the default behavior is to show the
value of the object you are hovering over when using the mouse.
Stub Completion
Another form of autocompletion called stub completion can be very useful
when working with interfaces or event handlers or when overriding a
method. This feature can be used to automatically stub out the methods
required by the interface or the default code for an overridden method or
event handler. This is a feature that was added to Visual Studio .NET 2003,
but its presence is not always obvious when you are coding quickly.
Interface. When you first create a class and add the interface name after the
colon (or the Implements in Visual Basic), a small yellow window will pop
up for just a few seconds, offering you the ability to press the Tab key, as
shown in Figure 2-10.
Figure 2-9. Parameter info IntelliSense pop up
Figure 2-10. Interface IntelliSense prompt
44
|
Chapter 2, Master the Editor
#8 Master IntelliSense
HACK
When you press the Tab key with this window still displayed, the methods
required by the interface will be automatically added to your class, includ-
ing TODO comments to remind you to complete the methods:
public class CarCollection : IEnumerable
{
public CarCollection( )
{
}
#region IEnumerable Members
public IEnumerator GetEnumerator( )
{
// TODO: Add CarCollection.GetEnumerator implementation
return null;
}
#endregion
}
Overriding methods. When you type override into the document window,
you will see a list of methods you can override in the base class. This can be
seen in Figure 2-11.
When you select the method you want to override, Visual Studio will create
the method and automatically add a call to the method you are overriding
on your base class like this:
public override void Start( )
{
base.Start ( );
}
Event handlers. When adding a new event handler to your class, Visual Stu-
dio will automatically create the stub of this event handler, much as when
working with an interface. When you type the code to add an event handler
to an event, you will see a prompt inviting you to press the Tab key, as
shown in Figure 2-12.
Figure 2-11. Override IntelliSense

Get Visual Studio Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.