gpt4 book ai didi

winforms - C# 中的元组函数(返回值)

转载 作者:行者123 更新时间:2023-12-02 04:19:32 27 4
gpt4 key购买 nike

如果你有以下函数,例如:

public Tuple<int, int> GetMultipleValue()
{
return Tuple.Create(1,2);
}

调用 GetMultipleValue() 后,您将如何在主程序中访问这些整数?

最佳答案

元组类具有具有非常“逻辑”名称的属性:Item1 , Item2 , Item3 ,...

Tuple<int, int> temp = GetMultipleValue();
Console.WriteLine("{0}; {1};", temp.Item1.ToString(), temp.Item2.ToString());

来自 MSDN Tuple <T1, T2> Class

关于winforms - C# 中的元组函数(返回值),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31438770/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com