vb.net 方括号在升级到 Visual Studio 2015 时导致错误

vb.net Square Brackets Cause Error When Upgraded to Visual Studio 2015

在将 vb.net 代码从 Visual Studio 2008 升级到 Visual Studio 2015 的过程中,我收到 'Integer' 未声明。由于其保护级别,它可能无法访问。 以下代码出现错误:

[Integer].TryParse(...)

错误也发生在与 [Date].TryParse 类似的代码上。原始代码和升级代码的目标框架都是 .NET Framework 3.5。升级目标框架并不重要。如果我删除方括号,代码将编译。有谁知道为什么这种语法在 Visual Studio 2008 中有效,但在 Visual Studio 2015 中无效?

由于@Plutonix @Blorgbeard 和@jmcilhinney 都在评论中回答,您需要删除方括号。转换为社区 wiki in line with this meta post 推荐,从 'Unanswered' 部分中删除。

@ jmcilhinney

The whole point of brackets is to indicate to the compiler that you want to use a keyword as an identifier. In this case, you're calling a Shared member of a type so you specifically DO want Integer or Date to be interpreted as a keyword, i.e. their intrinsic types. You'll sometimes see that done with String but that works because String is a .NET type. Integer and Date are not .NET types. The .NET types that correspond to those intrinsic types are Int32 and DateTime