什么是元组(T1)/辛格尔顿在.NET的目的是什么? [英] What's the purpose of the Tuple(T1)/Singleton in .net?

查看:187
本文介绍了什么是元组(T1)/辛格尔顿在.NET的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个.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?

推荐答案

您应该去问首创置业的设计师是肯定的,但我怀疑,因为有一个1元组在现实世界中,在.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.

元组是.NET实现你会考虑数学的概念元组的。

Tuples are the .NET implementation of what you'd consider the mathematical concept of a tuple.

现在,因为你要求编程使用的元组LT; T> ,我就同时答案有.NET语言(如F#),可以使用元组LT;> 的事情再presentation就像从函数的返回值。因为一个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+元组也可能是合法的,该休息属性可以是1元组重新present的溢出。

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

这篇关于什么是元组(T1)/辛格尔顿在.NET的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆