VB.NET相当于C#中var关键字 [英] VB.NET equivalent to C# var keyword

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

问题描述

有VB.NET等同于C# VAR 关键字?

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.

推荐答案

在VB.NET(VB9)省略类型将隐式类型变量。

Omitting the type in VB.NET (VB9) will implicitly type the variable.

这是的的一样VB.NET的previous版本选项关闭严,作为变量的的强类型,它只是做所以隐式(如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"

声明为字符串

选项推断必须是 为了这正常工作

Option Infer must be on in order for this to function properly

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

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