Re: How to determine read/write status of a property
Efran Cobisi <[email protected]> Mon, 25 Feb 2008 17:17:54 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Organization | cobisi.com |
| Message-ID | <[email protected]> |
Hi Chris,
You need to query the property's PropertyInfo class for its CanRead and
CanWrite boolean properties.
Type t = ...;
PropertyInfo pi = t.GetProperty("Name");
if (pi.CanRead)
...
if (pi.CanWrite)
...
HTH
--
Efran Cobisi
http://www.cobisi.com
chris Burgess wrote:
> How do I discover if a property is read only or read/write at runtime
> (other than trying to write to it)?
>
> e.g.
> If:
> Public ReadOnly Property Name() As String
> Get
> Return _name
> End Get
> End Property
>
> then I want the textbox on the form to be read only.
>
> If:
> Private _name As String
> Public Property Name() As String
> Get
> Return _name
> End Get
> Set(ByVal value As String)
> _name = value
> End Set
> End Property
>
> then I want the textbox to be read/write.
>
> Thanks,
>
> Chris
>
> ===================================
> This list is hosted by DevelopMentor® http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com