本文整理汇总了VB.NET中System.Reflection.MemberInfo.DeclaringType属性的典型用法代码示例。如果您正苦于以下问题:VB.NET MemberInfo.DeclaringType属性的具体用法?VB.NET MemberInfo.DeclaringType怎么用?VB.NET MemberInfo.DeclaringType使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.DeclaringType属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Reflection
Interface IValue
Function GetValue() As Integer
End Interface
Class A : Implements IValue
Public Overridable Function GetValue() As Integer _
Implements IValue.GetValue
Return 0
End Function
End Class
Class B : Inherits A
Public Shadows Function GetValue() As Integer
Return 0
End Function
End Class
Class C : Inherits A
End Class
Class D : Inherits A
Public Overrides Function GetValue() As Integer
Return 0
End Function
End Class
Public Module Example
Public Sub Main()
' Get members of IValue interface.
ShowMembersAndDeclaringTypes(GetType(IValue))
Console.WriteLine()
ShowMembersAndDeclaringTypes(GetType(A))
Console.WriteLine()
ShowMembersAndDeclaringTypes(GetType(B))
Console.WriteLine()
ShowMembersAndDeclaringTypes(GetType(C))
Console.WriteLine()
ShowMembersAndDeclaringTypes(GetType(D))
Console.WriteLine()
End Sub
Private Sub ShowMembersAndDeclaringTypes(t As Type)
Dim members() As MemberInfo = t.GetMembers()
Console.WriteLine("{0} Members: ", t.Name)
For Each member In members
Console.WriteLine(" {0}, Declaring type: {1}",
member.Name, member.DeclaringType.Name)
Next
End Sub
End Module
输出:
IValue Members: GetValue, Declaring type: IValue A Members: GetValue, Declaring type: A ToString, Declaring type: Object Equals, Declaring type: Object GetHashCode, Declaring type: Object GetType, Declaring type: Object .ctor, Declaring type: A B Members: GetValue, Declaring type: B GetValue, Declaring type: A ToString, Declaring type: Object Equals, Declaring type: Object GetHashCode, Declaring type: Object GetType, Declaring type: Object .ctor, Declaring type: B C Members: GetValue, Declaring type: A ToString, Declaring type: Object Equals, Declaring type: Object GetHashCode, Declaring type: Object GetType, Declaring type: Object .ctor, Declaring type: C D Members: GetValue, Declaring type: D ToString, Declaring type: Object Equals, Declaring type: Object GetHashCode, Declaring type: Object GetType, Declaring type: Object .ctor, Declaring type: D