本文整理匯總了VB.NET中System.Reflection.PropertyInfo.CanRead屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET PropertyInfo.CanRead屬性的具體用法?VB.NET PropertyInfo.CanRead怎麽用?VB.NET PropertyInfo.CanRead使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.CanRead屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Mypropertya
' 導入命名空間
Imports System.Reflection
' Define one readable property and one not readable.
Public Class Mypropertya
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
Public Class Mypropertyb
Private myCaption As String = "B Default caption"
Public WriteOnly Property Caption() As String
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")
' Define two properties.
Dim Mypropertya As New Mypropertya()
Dim Mypropertyb As New Mypropertyb()
Console.Write(ControlChars.Cr & "Mypropertya.Caption = " & _
Mypropertya.Caption)
' Mypropertyb.Caption cannot be read because
' there is no get accessor.
' Get the type and PropertyInfo.
Dim MyTypea As Type = Type.GetType("Mypropertya")
Dim Mypropertyinfoa As PropertyInfo = MyTypea.GetProperty("Caption")
Dim MyTypeb As Type = Type.GetType("Mypropertyb")
Dim Mypropertyinfob As PropertyInfo = MyTypeb.GetProperty("Caption")
' Get and display the CanRead property.
Console.Write(ControlChars.CrLf & "CanRead a - " & _
Mypropertyinfoa.CanRead)
Console.Write(ControlChars.CrLf & "CanRead b - " & _
Mypropertyinfob.CanRead)
Return 0
End Function
End Class