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 属性不是只读的并且可以设置?
基础教程推荐
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
