没有。 Tuple 类仅用于方法内部;如果您打算公开提供数据,则应为每个值定义一个 class 或 struct 属性。
但是,如果您想为您的值赋予有意义的名称,您可以改用匿名类型。这些是约束(不仅仅是打算),只能在方法内部使用。
var a = new { Name = "ABC", Age = 33, NumberOfFingers = 10 };
int age = a.Age;
编辑:如果您确信要从您的方法中返回一个元组,那么我的建议是在文档中解释它的结构以获取您的方法的返回值。
/// <summary>
/// Retrieves personal information about the person.
/// </summary>
/// <returns>
/// A tuple containing the following information:
/// <list type="bullet">
/// <item><see cref="Tuple{T1,T2,T3}.Item1"/>: The name of the person.</item>
/// <item><see cref="Tuple{T1,T2,T3}.Item2"/>: The age of the person.</item>
/// <item><see cref="Tuple{T1,T2,T3}.Item3"/>: The number of fingers the person has.</item>
/// </list>
/// </returns>
public Tuple<string, int, int> GetPerson()
{
return Tuple.Create("ABC", 33, 10);
}
如果您希望它显示在 IntelliSense 中,请将您的说明放在 <summary>。