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


VB.NET MemberInfo.DeclaringType属性代码示例

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

输出:

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


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