|
|
1
18
您必须要求BCL设计人员确定,但我怀疑,由于现实世界中存在一个1元组,.NET框架的作者希望在其实现中提供等效的对称性。
既然你在要求编程使用
您的8+元组示例也可能是合法的,因为
|
|
|
2
7
元组自动实现
By putting your data type into a tuple, even of only one element, you are guaranteed immutability, equatability, and comparability. For tuples consisting of only one element, the main benefit of using a tuple is going to be immutability: once the tuple is created, it's data can never change for the life of the tuple. |
|
3
4
|
|
|
4
3
Why use a 1-tuple, Tuple<T1> in C#? 可能的 usage of a 1-Tuple, is to return a null instance if there is no value, but that null of the item value itself, does not mean there is no result.
调用代码会知道当元组本身为空时,它不存在于列表中,但如果item1为空,则列表中实际上存在一个空项。当然,在本例中,存在许多更好的解决方法,但它也可以应用于数据库之外的结果:未找到结果或结果为空。 Extending that same logic, a Tuple can be used to easily create generic methods that can return null for any type. 例如
You could return
|