The '?' character cannot be used here

无人久伴 提交于 2019-12-05 02:37:22

VB.NET developers are not supposed to be using C# keywords (religion, you know). Seriously though, I agree with @Konrad this looks like a compiler bug. If you have other VS, try it there, I only tried in VS 2010 SP1, cause that's what I have at work. If you notice consistency, perhaps you should report it on connect. As a workaround, you can try this:

Dim flag3 As Boolean = d1.Equals(d1)
Dim flag4 As Boolean = i2.Equals(i1)

Or this:

Dim flag3 As Boolean = Nullable(Of DateTime).Equals(d1, d2)
Dim flag4 As Boolean = Nullable(Of Int32).Equals(i1, i2)

I personally prefer the last option in my code, to explicitly say Nullable(Of T), because VB language is supposed to be verbose, more English-like, i.e. no :? || && constructs (no offense, C# devs).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!