【问题标题】:Equivalent for nullable value check [duplicate]等效于可空值检查 [重复]
【发布时间】:2013-09-21 12:11:02
【问题描述】:

在 VB.net 中这个等价物是什么

int? x;

int s;

s = x ?? 5;

【问题讨论】:

  • vb.net 也有可以为空的类型。喜欢; Dim x As Integer?

标签: c# vb.net nullable


【解决方案1】:

vb.net 中声明可空的三种方式

Dim x? As Integer
Dim x As Integer?
Dim x As Nullable(Of Integer)


Dim s As Integer

s = If(x, 5)

【讨论】:

    【解决方案2】:

    if() 运算符是 vb 中的空值合并运算符。

    s = If(x, 5)
    

    【讨论】:

      猜你喜欢
      • 2019-04-08
      • 1970-01-01
      • 2021-01-04
      • 1970-01-01
      • 2017-04-20
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      • 2023-03-27
      相关资源
      最近更新 更多