首页 > 解决方案 > Tuple vs ValueTuple mutability

问题描述

Why is Tuple immutable, and ValueTuple mutable?

ValueTuple<string, string> valTup = new ValueTuple<string, string>("a", "b");
valTup.Item1 = "c";  // OK

Tuple<string, string> tup = new Tuple<string, string>("a", "b");
tup.Item1 = "c";  // Doesn't compile

标签: c#tuplesmutablevaluetuple

解决方案


推荐阅读