元組解決方案

你可以使用兩個模板引數 Tuple<string, MyClass> 從函式返回 Tuple 類的例項:

 placeholderCopypublic Tuple<string, MyClass> FunctionWith2ReturnValues ()
{
    return Tuple.Create("abc", new MyClass());
}

並閱讀如下的值:

 placeholderCopyConsole.WriteLine(x.Item1);
Console.WriteLine(x.Item2);