Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 如何在返回类型为泛型操作或Func的方法或属性中记录类型参数_.net_Generics_Type Parameter_Xml Documentation - Fatal编程技术网

.net 如何在返回类型为泛型操作或Func的方法或属性中记录类型参数

.net 如何在返回类型为泛型操作或Func的方法或属性中记录类型参数,.net,generics,type-parameter,xml-documentation,.net,Generics,Type Parameter,Xml Documentation,我有一个非常简单的问题,如何使用xmldoc记录返回类型为泛型Action或Func的方法或属性。 例如: /// <summary> /// Gets or sets the print method. Parameters: file, printer name??? /// </summary> /// <value> /// The print method. /// </value> public Action<string, s

我有一个非常简单的问题,如何使用xmldoc记录返回类型为泛型Action或Func的方法或属性。 例如:

/// <summary>
/// Gets or sets the print method. Parameters: file, printer name???
/// </summary> 
/// <value>
/// The print method.
/// </value>
public Action<string, string> PrintMethod { get; set; }
//
///获取或设置打印方法。参数:文件、打印机名称???
///  
/// 
///打印方法。
/// 
公共操作打印方法{get;set;}

在这种情况下,哪种做法是最好的

如果需要记录此操作的参数,请不要使用
操作
:而是创建自定义委托,并记录委托的参数

/// <summary>
/// Gets or sets the print method.
/// </summary> 
/// <value>
/// The print method.
/// </value>
public FilePrintAction PrintMethod { get; set; }

/// <summary>
/// Represents a method for printing a file to a printer
/// </summary> 
/// <parameter name="file">Path of the file to print</parameter>
/// <parameter name="printerName">Name of the printer</parameter>
public delegate void FilePrintAction(string file, string printerName);
//
///获取或设置打印方法。
///  
/// 
///打印方法。
/// 
公共文件PrintAction打印方法{get;set;}
/// 
///表示将文件打印到打印机的方法
///  
///要打印的文件的路径
///打印机名称
公共委托void FilePrintAction(字符串文件、字符串printerName);

这是一个很好的建议!但问题不在于是否使用操作或Func作为属性或方法的返回类型,而在于如何记录它。@Shurup,我的观点是,没有“干净”的方式记录操作或Func的参数;如果需要这样做,请创建一个特定的委托,您可以在该委托上记录参数。