当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Nullable.GetUnderlyingType方法代码示例

本文整理汇总了VB.NET中System.Nullable.GetUnderlyingType方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Nullable.GetUnderlyingType方法的具体用法?VB.NET Nullable.GetUnderlyingType怎么用?VB.NET Nullable.GetUnderlyingType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。


在下文中一共展示了Nullable.GetUnderlyingType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Sample

' This code example demonstrates the 
' Nullable.GetUnderlyingType() method.

Imports System.Reflection

Class Sample
    ' Declare a type named Example. 
    ' The MyMethod member of Example returns a Nullable of Int32.
    
    Public Class Example
        Public Function MyMethod() As Nullable(Of Integer)
            Return 0
        End Function
    End Class
    
' 
'   Use reflection to obtain a Type object for the Example type.
'   Use the Type object to obtain a MethodInfo object for the MyMethod method.
'   Use the MethodInfo object to obtain the type of the return value of 
'     MyMethod, which is Nullable of Int32.
'   Use the GetUnderlyingType method to obtain the type argument of the 
'     return value type, which is Int32.
'
    Public Shared Sub Main() 
        Dim t As Type = GetType(Example)
        Dim mi As MethodInfo = t.GetMethod("MyMethod")
        Dim retval As Type = mi.ReturnType
        Console.WriteLine("Return value type ... {0}", retval)
        Dim answer As Type = Nullable.GetUnderlyingType(retval)
        Console.WriteLine("Underlying type ..... {0}", answer)
    
    End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System,代码行数:33,代码来源:Nullable.GetUnderlyingType

输出:

Return value type ... System.Nullable`1[System.Int32]
Underlying type ..... System.Int32


注:本文中的System.Nullable.GetUnderlyingType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。