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 属性不是只读的并且可以设置?


- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01