【发布时间】:2013-04-05 12:24:29
【问题描述】:
怎么会在 C# 中这样做...
var x = new { Name = "aaa" };
...我可以在.Name 上获得智能感知,但是当我在 VB.NET 中执行此操作时...
Dim x = New With {.Name = "aaa"}
...我在.Name 上没有收到智能信号?
【问题讨论】:
标签: c# vb.net intellisense anonymous-types
怎么会在 C# 中这样做...
var x = new { Name = "aaa" };
...我可以在.Name 上获得智能感知,但是当我在 VB.NET 中执行此操作时...
Dim x = New With {.Name = "aaa"}
...我在.Name 上没有收到智能信号?
【问题讨论】:
标签: c# vb.net intellisense anonymous-types
这对我来说听起来很短暂。因为当我尝试时,
Dim x = New With {.Name = "aaa"}
显示
允许在声明变量时使用局部类型推断。
【讨论】:
option infer on。
option infer on 纳入您的答案中。
在这里回答我自己的问题。在VB.NET中,你必须使用模块级别option infer on。
我想在找出问题后删除这个问题,但是 1)我不能,因为这个问题已经有了答案,并且 2)我相信这无论如何都会对其他人有所帮助。
愉快的推理。
【讨论】: