Is there a version of the class Tuple whose Items properties are not readonly and can be set?(是否有一个版本的 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 属性不是只读的并且可以设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:是否有一个版本的 Tuple 类的 Items 属性不是只读的并且可以设置?
基础教程推荐
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
- 如果条件可以为空 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 从 C# 控制相机设备 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 将数据集转换为列表 2022-01-01
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
