本文整理匯總了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
示例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