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


VB.NET Type.IsInstanceOfType方法代码示例

本文整理汇总了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
开发者ID:VB.NET开发者,项目名称:System,代码行数:30,代码来源:Type.IsInstanceOfType

输出:

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.


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