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