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 属性不是只读的并且可以设置?
				
        
 
            
        基础教程推荐
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
 - 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
 - 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
 - JSON.NET 中基于属性的类型解析 2022-01-01
 - 全局 ASAX - 获取服务器名称 2022-01-01
 - 错误“此流不支持搜索操作"在 C# 中 2022-01-01
 - 如何动态获取文本框中datagridview列的总和 2022-01-01
 - 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
 - 首先创建代码,多对多,关联表中的附加字段 2022-01-01
 - 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
 
    	
    	
    	
    	
    	
    	
    	
    	
						
						
						
						
						
				
				
				
				