VB.NET 等效于 C# var 关键字 [英] VB.NET equivalent to C# var keyword

查看:34
本文介绍了VB.NET 等效于 C# var 关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有等效于 C# var 关键字的 VB.NET?

Is there a VB.NET equivalent to the C# var keyword?

我想用它来检索 LINQ 查询的结果.

I would like to use it to retrieve the result of a LINQ query.

推荐答案

Option Infer 必须开启才能正常运行.如果是这样,则在 VB.NET (Visual Basic 9) 中省略类型将隐式键入变量.

Option Infer must be on in order for this to function properly. If so, then omitting the type in VB.NET (Visual Basic 9) will implicitly type the variable.

这与以前版本的 VB.NET 中的Option Strict Off"不同,因为变量强类型的;它只是隐式地完成(如 C# var)关键字.

This is not the same as "Option Strict Off" in previous versions of VB.NET, as the variable is strongly-typed; it's just done so implicitly (like the C# var) keyword.

Dim foo = "foo"

foo 被声明为 String.

这篇关于VB.NET 等效于 C# var 关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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