.net 中的 Tuple(T1)/Singleton 的目的是什么?

What#39;s the purpose of the Tuple(T1)/Singleton in .net?(.net 中的 Tuple(T1)/Singleton 的目的是什么?)
本文介绍了.net 中的 Tuple(T1)/Singleton 的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.net 4 中的元组类型之一是 单元素元组.我只是想知道这个结构的目的是什么?

One of the Tuple Types in .net 4 is a Single-Element Tuple. I just wonder what the purpose of this struct is?

我看到的唯一用途是在 8+ 元组 因为它可以分配给 TREST,它实际上是有意义的.是这样吗?还是有其他目的?

The only use I saw is when using in the 8+ Tuple as it can be assigned to TRest, where it actually makes sense. Is that it? Or is there any other purpose?

推荐答案

你得问 BCL 设计者才能确定,但​​我怀疑既然现实世界中有一个 1-tuples,.NET 框架作者希望在他们的实现中提供等效的对称性.

You'd have to ask the BCL designers to be certain, but I suspect that since there is a 1-tuples in the real world, the .NET framework authors wanted to provide equivalent symmetry in their implementation.

Tuples 是您认为的 数学概念的 .NET 实现一个元组.

现在,既然您要求 Tuple<T> 的编程用途,我会回答有 .NET 语言(如 F#)可以使用 Tuple<> 用于表示函数的返回值等事物.由于 F# 函数肯定会返回一个 1 元组作为结果 - 它为语言的行为和感觉增加了对称性和一致性.

Now since you're asking for programming uses for Tuple<T>, I would also answer that there are .NET languages (like F#) that could use Tuple<> for representation of things like return values from functions. Since an F# function could certainly return a 1-tuple as a result - it adds symmetry and consistency to the behavior and feel of the language.

您的包含 8 个以上元组的示例也可能是合法的,因为 Rest 属性可以是表示溢出"的 1 元组.

Your example with 8+ tuples is also probably legitimate, in that the Rest property could be a 1-tuple to represent the "overflow".

这篇关于.net 中的 Tuple(T1)/Singleton 的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
quot;Overflowquot; compiler error with -9223372036854775808L(编译器错误-9223372036854775808L(Q;溢出Q))
Visual Studio 2010 ReportViewer Assembly References(Visual Studio 2010 ReportViewer程序集引用)
Weird behaviour when I open a reportviewer in WPF(在WPF中打开报表查看器时出现奇怪的行为)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)