本文整理汇总了VB.NET中System.Type.IsInstanceOfType方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Type.IsInstanceOfType方法的具体用法?VB.NET Type.IsInstanceOfType怎么用?VB.NET Type.IsInstanceOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Type
的用法示例。
在下文中一共展示了Type.IsInstanceOfType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
Public Interface IExample
End Interface
Public Class BaseClass : Implements IExample
End Class
Public Class DerivedClass : Inherits BaseClass
End Class
Public Module Example
Public Sub Main()
Dim interfaceType As Type = GetType(IExample)
Dim base1 As New BaseClass()
Dim base1Type As Type = base1.GetType()
Dim derived1 = New DerivedClass()
Dim derived1Type As Type = derived1.GetType()
Dim arr(10) As Integer
Console.WriteLine("Is int[] an instance of the Array class? {0}.",
GetType(Array).IsInstanceOfType(arr))
Console.WriteLine("Is base1 an instance of BaseClass? {0}.",
base1Type.IsInstanceOfType(base1))
Console.WriteLine("Is derived1 an instance of BaseClass? {0}.",
base1Type.IsInstanceOfType(derived1))
Console.WriteLine("Is base1 an instance of IExample? {0}.",
interfaceType.IsInstanceOfType(base1))
Console.WriteLine("Is derived1 an instance of IExample? {0}.",
interfaceType.IsInstanceOfType(derived1))
End Sub
End Module
输出:
Is int[] an instance of the Array class? True. Is base1 an instance of BaseClass? True. Is derived1 an instance of BaseClass? True. Is base1 an instance of IExample? True. Is derived1 an instance of IExample? True.