How do you provide XML comments / documentation for delegate options?

for delegate type

Func<string,string,string> MyFunc = (firstName,lastName) => string.Format("Given Name:{0} Surname:{1}", firstName, lastName); 

How can you document the firstName and lastName parameters so that they appear in intellisense (e.g. method descriptions and parameters)?
Example:

 /// <summary> /// My Method /// </summary> /// <param name="firstName">The first name.</param> /// <param name="lastName">The last name.</param> /// <returns></returns> public string MyMethod(string firstName, string lastName) { return string.Format("Given Name:{0} Surname:{1}",firstName,lastName); } 

I want to hover over a delegate or pop up intellisense as I type in and tell me the delegate parameter descriptions, as it would with the above method.

+6
comments c # delegates
source share
1 answer

The delegate type field is still a field, not a method. It does not take parameters on its own. Parameters belong to the delegate type, not the delegate field. You can write comments for parameters when delegating types, if you want.

 /// <summary> /// Tests something. /// </summary> /// <param name="test">Something that going to be tested.</param> delegate void Test(int test); 

Func<string,string,string> is the general delegate for functions with three parameters. For specific purposes, you can always declare your own delegate type, which will represent the abstracted method, and add comments to its parameters.

+8
source share

All Articles