匿名类型和元组 [英] Anonymous type and tuple

查看:85
本文介绍了匿名类型和元组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

匿名类型和元组有什么区别?

What is the difference between anonymous type and tuple?

推荐答案

匿名类型的属性名称包含更多信息,对于元组而言,您没有此名称.但是,您不能使用匿名类型作为返回值和参数,而可以使用元组.

Anonymous types have property names which carry more information, for tuples you don't have this. You can't use anonymous types as return values and parameters though and you can with tuples.

当元组很好时,您想返回多个值的例子. @Petar Minchev 提到了此链接,这是一个很好的例子.

An example of when a tuple is nice is when you want to return multiple values. @Petar Minchev mentions this link which gives a good example.

您可能需要一个同时返回索引和值的Find()方法.另一个例子是在2d或3d平面中的位置.

You may want a Find() method that returns both an index and the value. Another example would be the position in a 2d or 3d plane.

这篇关于匿名类型和元组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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