Friday, 15 May 2015

c# - Visual Studio autocomplete event handler with lambda format -



c# - Visual Studio autocomplete event handler with lambda format -

i'm on vs2012 , want utilize lambda format event handling, vs autocomplete tab key whenever type event subscrition via +=, e.g.:

vs autocompleted reference function inserts function:

txttitle.textchanged += txttitle_textchanged; void txttitle_textchanged(object sender, textchangedeventargs e) { .... }

is there way forcefulness autocomplete lambda format of:

txttitle.textchanged += (object sender, textchangedeventargs e) => { .... }

its huge pain have re-create , paste autocompleted non-lambda tighter lambda format.

you can create code snippet, have 1 creating lambda events.

here snippet if want seek (just save whatever.snippet) , import in vs (tools -> code snippet manager)

snippet:

<?xml version="1.0" encoding="utf-8"?> <codesnippets xmlns="http://schemas.microsoft.com/visualstudio/2005/codesnippet"> <codesnippet format="1.0.0"> <header> <snippettypes> <snippettype>expansion</snippettype> </snippettypes> <title>snippetfile1</title> <author>sa_ddam213</author> <description> </description> <helpurl> </helpurl> <shortcut>le</shortcut> </header> <snippet> <declarations> <literal editable="true"> <id>s</id> <tooltip>s</tooltip> <default>s</default> <function> </function> </literal> <literal editable="true"> <id>e</id> <tooltip>e</tooltip> <default>e</default> <function> </function> </literal> </declarations> <code language="csharp" kind="method body"><![cdata[($s$,$e$) => { };]]></code> </snippet> </codesnippet> </codesnippets>

then utilize type eventname += le tab

example

loaded += le tab

result

loaded += (s, e) => { };

c# visual-studio lambda event-handling intellisense

No comments:

Post a Comment