代码之家  ›  专栏  ›  技术社区  ›  Hath

C#的默认值(T)的VB等价物

  •  43
  • Hath  · 技术社区  · 15 年前

    VB与C的等价物是什么 default(T) - default operator

    2 回复  |  直到 3 年前
        1
  •  50
  •   Ian Horwill    5 年前

    这是其中的任何一种:

    Dim variable As T
    Dim variable As T = Nothing
    Dim variable As New T()
    Dim variable As T = CType(Nothing, T) 'this is suggested by reflector
    

    分配 Nothing New Structure

        2
  •  48
  •   Stephen Kennedy annamataws    7 年前

    最接近于 default(T) 真是 CType(Nothing, T) 默认值(T) 使用(即作为表达式)。