What#39;s the purpose of the Tuple(T1)/Singleton in .net?(.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 的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:.net 中的 Tuple(T1)/Singleton 的目的是什么?


基础教程推荐
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01