本文整理汇总了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
输出:
Return value type ... System.Nullable`1[System.Int32] Underlying type ..... System.Int32