本文整理汇总了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