本文整理匯總了VB.NET中System.Reflection.PropertyInfo.GetSetMethod方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET PropertyInfo.GetSetMethod方法的具體用法?VB.NET PropertyInfo.GetSetMethod怎麽用?VB.NET PropertyInfo.GetSetMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.GetSetMethod方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Myproperty
' 導入命名空間
Imports System.Reflection
' Define a property.
Public Class Myproperty
Private myCaption As String = "A Default caption"
Public Property Caption() As String
Get
Return myCaption
End Get
Set(ByVal Value As String)
If myCaption <> value Then
myCaption = value
End If
End Set
End Property
End Class
Class Mypropertyinfo
Public Shared Function Main() As Integer
Console.WriteLine(ControlChars.CrLf & "Reflection.PropertyInfo")
' Get the type and PropertyInfo for two separate properties.
Dim MyTypea As Type = Type.GetType("Myproperty")
Dim Mypropertyinfoa As PropertyInfo = MyTypea.GetProperty("Caption")
Dim MyTypeb As Type = Type.GetType("System.Text.StringBuilder")
Dim Mypropertyinfob As PropertyInfo = MyTypeb.GetProperty("Length")
' Get and display the GetSetMethod method for each property.
Dim Mygetmethodinfoa As MethodInfo = Mypropertyinfoa.GetSetMethod()
Console.WriteLine("SetAccessor for " & Mypropertyinfoa.Name & _
" returns a " & Mygetmethodinfoa.ReturnType.ToString())
Dim Mygetmethodinfob As MethodInfo = Mypropertyinfob.GetSetMethod()
Console.WriteLine("SetAccessor for " & Mypropertyinfob.Name & _
" returns a " & Mygetmethodinfob.ReturnType.ToString())
' Display the GetSetMethod without using the MethodInfo.
Console.WriteLine(MyTypea.FullName & "." & Mypropertyinfoa.Name & _
" GetSetMethod - " & Mypropertyinfoa.GetSetMethod().ToString())
Console.WriteLine(MyTypeb.FullName & "." & Mypropertyinfob.Name & _
" GetSetMethod - " & Mypropertyinfob.GetSetMethod().ToString())
Return 0
End Function
End Class