Visual Studio 2010中的C#事件订阅

Ent*_*ity 6 .net c# keyboard-shortcuts event-handling visual-studio-2010

所以,在visual studio中,如果你键入这样的东西:

retryExecutor.Retrying += 
Run Code Online (Sandbox Code Playgroud)

然后弹出一个小工具提示,说你可以按TAB它把它变成这个:

retryExecutor.Retrying+= new EventHandler(retryExecutor_Retrying);
Run Code Online (Sandbox Code Playgroud)

然后,如果TAB再次按,它会生成:

void retryExecutor_Retrying(object sender, EventArgs e)
{
    throw new NotImplementedException();
}
Run Code Online (Sandbox Code Playgroud)

当然,这非常有用.但我发现自己经常需要这样的结构:

retryExecutor.Retrying += (o, e) =>
{

};
Run Code Online (Sandbox Code Playgroud)

那么,无论如何都要添加一个新的快捷方式,或者至少改变按下的功能TAB

Teo*_*gul 2

您始终可以创建并使用 IntelliSense 代码片段。在这里阅读更多相关信息:http://msdn.microsoft.com/en-us/library/ms165392%28v=VS.100%29.aspx