以及何时使用何种元组? [英] What and When to use Tuple?

查看:315
本文介绍了以及何时使用何种元组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能有的请解释什么是元组是在真实的场景中你将如何使用它。我想找出如何能丰富我的编码经验?

解决方案

MSDN文章 举例说明它非常好,元组是一种数据结构,有一个具体的数字和元素序列的。

  

元组中常用的四种方式:

     
      
  1. 要重新present一组数据。例如,一个元组可以   再present数据库记录,并且其组件可以重新present   记录的各个领域。

  2.   
  3. 要提供方便的,操控性,一个数据集。

  4.   
  5. 要在不使用输出参数从方法返回多个值   (在C#)或者的ByRef 参数(在Visual Basic)。

  6.   
  7. 要通过一个参数传递多个值的方法。对于   例如, Thread.Start(对象)方法有一个参数   允许您提供一个值,该线程执行的方法   启动时间。如果提供了元组LT; T1,T2,T3> 对象的方法   参数,您可以提供三个线程的启动程序   数据项。

  8.   

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:

  1. 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.

  2. To provide easy access to, and manipulation of, a data set.

  3. To return multiple values from a method without using out parameters (in C#) or ByRef parameters (in Visual Basic).

  4. 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.

这篇关于以及何时使用何种元组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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