如何拆箱元组?
How to unbox tuple?
我有盒装元组:
(int, string) tuple = (1, "abc");
object box = tuple;
如何从box
获取元组?将 object
转换回元组的正确语法是什么?
我的尝试:
var deconstruct = (int, string)box;
明显错误:
Error CS1525 Invalid expression term 'int'
Error CS1525 Invalid expression term 'string'
Error CS1002 ; expected
Error CS0201 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
ValueTuple<int, string> t = (ValueTuple<int, string>)box;
或
(int, string) t = ((int, string))box;
我有盒装元组:
(int, string) tuple = (1, "abc");
object box = tuple;
如何从box
获取元组?将 object
转换回元组的正确语法是什么?
我的尝试:
var deconstruct = (int, string)box;
明显错误:
Error CS1525 Invalid expression term 'int'
Error CS1525 Invalid expression term 'string'
Error CS1002 ; expected
Error CS0201 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
ValueTuple<int, string> t = (ValueTuple<int, string>)box;
或
(int, string) t = ((int, string))box;