Likewise, the iteration variable of a foreach statement (8.8.4) may be declared as an implicitly typed local variable, in which case the type of the iteration variable is inferred to be the element type of the collection being enumerated.
基于1个网页-相关网页
implicitly typed local variable 隐式类型本地变量 ; 类型局部变量 ; 隐含型别区域变数
This means that you can easily access members directly off a returned object, or you can assign it to a strongly typed local variable without having to cast.
这意味着你可以直接在返回的对象上访问成员,或者可以使用强类型的局部变量为其赋值,而无需进行转换。
Also as the name says, implicitly typed local variable, you cannot use var for field declaration or constant variables, therefore following declarations will both produce a compiler error.
故名思意,“隐式类型局部变量”将无法用于域变量或常量的声明中,否则将导致编译错误。
应用推荐