是否有一个版本的 Tuple 类的 Items 属性不是只读的并且可以设置? [英] Is there a version of the class Tuple whose Items properties are not readonly and can be set?

查看:16
本文介绍了是否有一个版本的 Tuple 类的 Items 属性不是只读的并且可以设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道有没有内置版本的Tuple类,其Items属性不是readonly,可以设置.

I want to know whether there is a built-in version of the class Tuple whose Items properties are not readonly and can be set.

或者谁能给我这样的版本?

Or can someone provide me such a version?

我正在寻找实现 Tuple 类的基本功能的解决方案,(Equals, GetHashCode)

I am searching for a solution that implements the base functions of the Tuple class, (Equals, GetHashCode)

推荐答案

不,如前所述,Tuple<> 旨在是不可变的.

No, as mentioned a Tuple<> is intended to be immutable.

如果我需要一个可变类型来做同样的事情,我会使用自定义的 Pair 类,尽管本着拥抱函数概念的精神,我尽量不使用它.

I use a custom Pair class if I need a mutable type that does the same thing, although in the spirit of embracing function concepts, I try not to use it.

namespace StackOverflow.Helpers
{
    public class Pair<T1, T2>
    {
        public T1 First { get; set; }
        public T2 Second { get; set; }
    }
} 

这篇关于是否有一个版本的 Tuple 类的 Items 属性不是只读的并且可以设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆