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


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

本文整理汇总了VB.NET中System.Reflection.MemberInfo.MemberType属性的典型用法代码示例。如果您正苦于以下问题:VB.NET MemberInfo.MemberType属性的具体用法?VB.NET MemberInfo.MemberType怎么用?VB.NET MemberInfo.MemberType使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Reflection.MemberInfo的用法示例。


在下文中一共展示了MemberInfo.MemberType属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Mymemberinfo

' 导入命名空间
Imports System.Reflection

Class Mymemberinfo

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.Cr + "Reflection.MemberInfo")

        ' Get the Type and MemberInfo.
        Dim MyType As Type = Type.GetType("System.Reflection.PropertyInfo")
        Dim Mymemberinfoarray As MemberInfo() = MyType.GetMembers()

        ' Get the MemberType method and display the elements.
        Console.Write(ControlChars.Cr + "There are {0} members in ", _
           Mymemberinfoarray.GetLength(0))
        Console.Write("{0}.", MyType.FullName)

        Dim counter As Integer
        For counter = 0 To Mymemberinfoarray.Length - 1
            Console.Write(ControlChars.CrLf + counter.ToString() + ". " _
               + Mymemberinfoarray(counter).Name _
               + " Member type - " _
               + Mymemberinfoarray(counter).MemberType.ToString())
        Next counter
        Return 0
    End Function
End Class
开发者ID:VB.NET开发者,项目名称:System.Reflection,代码行数:27,代码来源:MemberInfo.MemberType

示例2: MainClass

' 导入命名空间
Imports System.Reflection


Public Class MainClass

   Public Shared Sub Main()
        Dim Book = New Derived()

        Dim Member As MemberInfo
        Console.WriteLine("Members:")
        For Each Member In Book.GetType.GetMembers()
            Console.WriteLine(Member.Name & " " & Member.MemberType)
        Next

        Dim PropertyObj As PropertyInfo
        Console.WriteLine("Properties:")
        For Each PropertyObj In Book.GetType.GetProperties()
            Console.WriteLine(PropertyObj.Name & " " & PropertyObj.PropertyType.ToString())
        Next

        Dim MethodObj As MethodInfo
        Console.WriteLine("Methods:")
        For Each MethodObj In Book.GetType.GetMethods()
            Console.WriteLine(MethodObj.Name & " " & MethodObj.ReturnType.ToString())
        Next

        Dim EventObj As EventInfo
        Console.WriteLine("Events:")
        For Each EventObj In Book.GetType.GetEvents()
            Console.WriteLine(EventObj.Name & " " & EventObj.IsMulticast)
        Next

        Dim InterfaceObj As Type
        Console.WriteLine("Events:")
        For Each InterfaceObj In Book.GetType.GetInterfaces()
            Console.WriteLine(InterfaceObj.Name)
        Next

   
   End Sub

End Class 
    Class Base
        Public ProductID As String
        Public Weight As Double
        Private ProductPrice As Double

        Public Sub New()
        End Sub

        Public ReadOnly Property Price() As Double
            Get
                Return 0
            End Get
        End Property

    End Class

    Class Derived
        Inherits Base
        Implements IFormattable

        Public Title As String
        Public Author As String
        Public Publisher As String

        Public Overridable Overloads Function ToString(ByVal _
          Format As String, ByVal Provider As IFormatProvider) _
          As String Implements IFormattable.ToString

            ToString = Title

        End Function

        Public Sub New()
            MyBase.New()

        End Sub

    End Class
开发者ID:VB程序员,项目名称:System.Reflection,代码行数:81,代码来源:MemberInfo.MemberType


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