【问题标题】:Correct XML comments for return value of generic method更正通用方法返回值的 XML 注释
【发布时间】:2013-08-10 21:04:38
【问题描述】:

我需要为方法登录的返回值创建 XML 注释。此方法返回对象类型 结果。如果登录成功,则此对象包含会话 ID,如果登录不成功则包含错误消息。

我不知道如何在 XML 注释中描述这一点。

/// <summary>
/// Login to server
/// </summary>
/// <param name="name">Name of user</param>
/// <param name="password">User password</param>
/// <returns>
/// This method return object type of Result<Account>
/// If login was successful contains sessions 
/// If login was unsuccessful contains error
/// </returns>
Result<Account> Login(string name, string password);

/// <summary>
/// Return value of method
/// </summary>
/// <typeparam name="T">Type of return value</typeparam>
public class Result<T>
{
    /// <summary>
    /// Return message
    /// </summary>
    public string ResultMessage { get; set; }

    /// <summary>
    /// Return value
    /// </summary>
    public T ReturnValue { get; set; }
}


public class Account
{
  public string Name{get;set;}

  public string Password {get;set;}

  public string Session {get;set;
}

感谢您的建议。

【问题讨论】:

    标签: c# xml-comments generic-method


    【解决方案1】:

    你会使用:

    /// ...
    /// This method returns an object of type <see cref="Result{Account}"/>.
    /// ...
    

    cref Attribute

    【讨论】:

    • 感谢您的快速回答。
    猜你喜欢
    • 1970-01-01
    • 2012-08-01
    • 2017-11-22
    • 1970-01-01
    • 2013-07-17
    • 2015-01-13
    • 2014-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多