How to autocomplete a delegate in Visual Studio
How do you autocomplete a method signature based on a delegate? Or atleast get some help from intellisense in completing the method signature.
Some method has a delegate as one of its parameters, so I have to create the method, call me lazy but it's quite painful to copy paste the method signature from MSDN.
I recall that when you specify an event handler, Visual Studio has an autocomplete feature for you (by hitting tab), but I wonder if th开发者_高级运维is is possible for other kind of delegates.
It is possible - just type the name of the new method where the delegate parameter is expected, press Ctrl+. (quick actions) and choose "Generate method...".
For example, you can do Shell.Current.Navigated += GetDelegate;
, Ctrl+. (or click the quick actions icon (
private void GetDelegate(object sender, ShellNavigatedEventArgs e)
{
throw new NotImplementedException();
}
Then just copy the signature from there and delete the generated method:
Shell.Current.Navigated += (object sender, ShellNavigatedEventArgs e) =>
{
};
You can't do this unless your are subscribing to an event. It can be a custom event of course.
But for other delegates not possible.
精彩评论