可能有的请解释什么是元组是在真实的场景中你将如何使用它。我想找出如何能丰富我的编码经验?
解决方案这 MSDN文章 举例说明它非常好,元组是一种数据结构,有一个具体的数字和元素序列的。
元组中常用的四种方式:
要重新present一组数据。例如,一个元组可以 再present数据库记录,并且其组件可以重新present 记录的各个领域。
要提供方便的,操控性,一个数据集。
要在不使用输出参数从方法返回多个值
(在C#)或者的ByRef
参数(在Visual Basic)。
要通过一个参数传递多个值的方法。对于
例如, Thread.Start(对象)
方法有一个参数
允许您提供一个值,该线程执行的方法
启动时间。如果提供了元组LT; T1,T2,T3>
对象的方法
参数,您可以提供三个线程的启动程序
数据项。
May some please explain what a Tuple is and how would you use it in a Real World Scenario. I would like to find out how this can enrich my coding experience?
解决方案This msdn article explains it very well with examples, "A tuple is a data structure that has a specific number and sequence of elements".
Tuples are commonly used in four ways:
To represent a single set of data. For example, a tuple can represent a database record, and its components can represent individual fields of the record.
To provide easy access to, and manipulation of, a data set.
To return multiple values from a method without using out parameters
(in C#) or ByRef
parameters (in Visual Basic).
To pass multiple values to a method through a single parameter. For
example, the Thread.Start(Object)
method has a single parameter that
lets you supply one value to the method that the thread executes at
startup time. If you supply a Tuple<T1, T2, T3>
object as the method
argument, you can supply the thread’s startup routine with three
items of data.