Uma*_*man 4 c# methods return visual-studio c#-3.0
我一直在 Visual Studio 中使用 C# 使用我的软件。但是我想在我的方法中返回多个值,如何在 C# 中的一个方法中返回多个值......这可能吗?
您可以使用 .NET 4.0+ 的元组:
例如:
public Tuple<int, int> GetMultipleValue()
{
return Tuple.Create(1,2);
}
Run Code Online (Sandbox Code Playgroud)
现在容易多了
例如:
public (int, int) GetMultipleValue()
{
return (1,2);
}
Run Code Online (Sandbox Code Playgroud)