隐式类型VS匿名类型 [英] Implicitly Typed vs Anonymous Type
本文介绍了隐式类型VS匿名类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它是相同的或者是不同的,所以什么是隐式类型的和匿名类型之间的主要区别隐式类型的和匿名Type.If什么区别吗?
Is it same or any difference between Implicitly Typed and Anonymous Type.If it is different so What is the main difference between Implicitly Typed and Anonymous Type?
推荐答案
有一个巨大的差别:
隐式类型(本地)变量,是哪种类型的未明确给出变量:
Implicitly typed (local) variables, are variables which type is not explicitly given:
var i = new StringBuilder();
现在,我
隐式类型的的StringBuilder
- 命名类型
Now, i
is implicitly of type StringBuilder
- a named type.
在另一边匿名类型没有名字,他们的匿名的:
Anonymous types on the other side do not have a name, they are anonymous:
var x = new { Foo = "Bar" };
现在x是一个匿名类型,具有只读属性富
。
x is now of an anonymous type, with a read-only property Foo
.
这篇关于隐式类型VS匿名类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文