#595 – Intellisense Shows Method Overloads
May 31, 2012 5 Comments
When you overload a method, you’re creating multiple methods with the same name, but a different number of parameters, or parameters of different types. At compile-time, the compiler will automatically call the correct method.
Visual Studio can help with entering parameter values. When you enter the name of a method, Intellisense shows you a list of available methods with that name.
Let’s say that we have three different versions of a Dog.Bark method. After typing “Bark” and the opening parenthesis “(“, Intellisense will indicate that there are three versions of the method available and provide information about the first version.
At this point, you can press the up/down arrow keys to cycle through the three different methods.
Notice that Intellisense does the following:
- Indicates in bold the next parameter that you should enter
- Lists a description of the method, if one is available
- Provides a description of the next parameter
Hi Shawn,
I using VS 2012RC. When hovering over method – intellisense shows brief description spec and “+9 overload(s)” message.
But it does not offer any way to scroll or to see through available overloads.
Is it possible to make it work?
Thanks
You can cycle through the various overloads if you’re not hovering over the method, but entering the parameters for the method. If you delete all of the parameters and just enter the opening parenthesis, you’ll see a tooltip that indicates “1 of 10” and an up and down arrow on either side of the “1 of 10” indicator. At this point, you can use the up/down arrow keys to cycle through all of the overloads.
Sean
Thanks Sean.
This works for .cs files, but apparently not for .chtml
For example @Html.ActionLink … will show that +9 more overloads aailable, but no arrows to scroll through them. Not at least in my experience.
I wonder if there is an extension in existence to help with that?
How do I select the overload so its injected into the line of code I’ve tried everything enter/tab/space? Its been really getting in the way of work….
Matt, for method overloads, autocomplete is not an option. In this case, Intellisense is only displayed for reference. As you type, Intellisense will try to interpret which overload you are trying to use and will update its context automatically, or you can use the arrows to manually select the overload you want to see. The Intellisense window remains visible (for reference only) until you complete the definition. You can press the ESC key to get rid of it if you don’t want to see it on a one-time basis. You can also turn off Intellisense completely in the Text Editor section of Options.