Visual Studio can read your mind. Learn how to have Visual Studio's IntelliSense feature do lots of the
typing for you.
Even if you have used Visual Studio only a couple times, I am sure you have noticed one of its trademark
features: IntelliSense. The most popular form of IntelliSense assists you as you code by providing a list of the
members for each class immediately after you finish typing the class name (and the following period). This is not
the only form of IntelliSense though; this feature finds its way into a multitude of different areas of Visual Studio.
Complete Word
The first, and most useful, IntelliSense feature is actually just a shortcut: Ctrl-Space (Edit.CompleteWord).
By using the Ctrl-Space shortcut, you can summon IntelliSense at any point during your coding session, not just
when you finish typing a class name. This is one of the few shortcuts that can really change the way that you
write code.
If you have already starting typing when you press Ctrl-Space, Visual Studio will take one of two actions. If there
is only one object that matches what you have typed in so far, it will automatically complete the object name; for
instance, if you typed in HttpR, it would automatically complete the rest of the object name (HttpRequest). If
there are a number of objects that match what you have typed in, it will display the full list of members with the
first match highlighted. Figure shows what the listbox would look like if you only typed in the letter P.
You can also press Ctrl-Space on a blank line and be shown a complete list of members in the current context.
This is a great way to find a variable name that has slipped your mind. Figure shows an example of this.
This shortcut can be even more useful if you name all of your private member variables with a common prefix; for
instance, if all of your variables are prefixed with "_", by typing _ and then pressing Ctrl-Space, you would display
a list of all of your variables to choose from.
No comments:
Post a Comment