本文整理匯總了VB.NET中System.Type.IsSubclassOf方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Type.IsSubclassOf方法的具體用法?VB.NET Type.IsSubclassOf怎麽用?VB.NET Type.IsSubclassOf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Type
的用法示例。
在下文中一共展示了Type.IsSubclassOf方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
Public Class Class1
End Class
Public Class DerivedC1 : Inherits Class1
End Class
Public Module Example
Public Sub Main()
Console.WriteLine("DerivedC1 subclass of Class1: {0}",
GetType(DerivedC1).IsSubClassOf(GetType(Class1)))
End Sub
End Module
輸出:
DerivedC1 subclass of Class1: True
示例2: Example
Public Interface IInterface
Sub Display()
End Interface
Public Class Implementation : Implements IInterface
Public Sub Display() _
Implements IInterface.Display
Console.WriteLine("The implementation...")
End Sub
End Class
Module Example
Public Sub Main()
Console.WriteLine("Implementation is a subclass of IInterface: {0}",
GetType(Implementation).IsSubclassOf(GetType(IInterface)))
Console.WriteLine("IInterface is assignable from Implementation: {0}",
GetType(IInterface).IsAssignableFrom(GetType(Implementation)))
End Sub
End Module
輸出:
Implementation is a subclass of IInterface: False IInterface is assignable from Implementation: True