Class

# PropertyInfo

<div class="rst-class">

forsearch

</div>

Introspection

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to get information about properties via the `Introspection</api/language/introspection/introspection>` system.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                      | Type                                             | Read-Only | Shared |
|-------------------------------------------|--------------------------------------------------|-----------|--------|
| `CanRead<propertyinfo.canread>`           | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `CanWrite<propertyinfo.canwrite>`         | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsComputed<propertyinfo.iscomputed>`     | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsPrivate<propertyinfo.isprivate>`       | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsProtected<propertyinfo.isprotected>`   | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsPublic<propertyinfo.ispublic>`         | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `IsShared<propertyinfo.isshared>`         | `Boolean</api/data_types/boolean>`               | ✓         |        |
| `Name<propertyinfo.name>`                 | `String</api/data_types/string>`                 | ✓         |        |
| `PropertyType<propertyinfo.propertytype>` | `TypeInfo</api/language/introspection/typeinfo>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                        | Parameters                                                                                                                              | Returns                                                      | Shared |
|---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|--------|
| `GetAttributes<propertyinfo.getattributes>` |                                                                                                                                         | `AttributeInfo()</api/language/introspection/attributeinfo>` |        |
| `Value<propertyinfo.value>`                 | obj As `Object</api/data_types/additional_types/object>`                                                                                | `Variant</api/data_types/variant>`                           |        |
|                                             | base As `Object</api/data_types/additional_types/object>`, `Assigns</api/language/assigns>` value As `Variant</api/data_types/variant>` |                                                              |        |

## Property descriptions

<div id="propertyinfo.canread">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.CanRead

**CanRead** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the property is a simple value property or has a Get accessor.
>
> This property is read-only.
>
> This example checks the CanRead property before taking an action.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
> Var myProperties() As Introspection.PropertyInfo = Introspection.GetType(d).GetProperties
>
> For Each prop As Introspection.PropertyInfo In myProperties
>   If prop.CanRead Then
>     ' take action here
>   End If
> Next
> ```

<div id="propertyinfo.canwrite">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.CanWrite

**CanWrite** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the property is a simple value property or has a Set accessor.
>
> This property is read-only.
>
> This example checks the CanRead property before taking an action.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
> Var myProperties() As Introspection.PropertyInfo = Introspection.GetType(d).GetProperties
>
> For Each prop As Introspection.PropertyInfo In myProperties
>   If prop.CanWrite Then
>     ' take action here
>   End If
> Next
> ```

<div id="propertyinfo.iscomputed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.IsComputed

**IsComputed** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, it is a computed property.
>
> This property is read-only.

<div id="propertyinfo.isprivate">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.IsPrivate

**IsPrivate** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the item has Private scope.
>
> This property is read-only.
>
> The following example checks the IsPrivate property before taking an action.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   If prop.IsPrivate Then
>     ' take an action here..
>   End If
> Next
> ```

<div id="propertyinfo.isprotected">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.IsProtected

**IsProtected** As `Boolean</api/data_types/boolean>`

> Is `True</api/language/true>`, the item has Protected scope.
>
> This property is read-only.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   If prop.IsProtected Then
>     ' take an action here..
>   End If
> Next
> ```

<div id="propertyinfo.ispublic">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.IsPublic

**IsPublic** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the item has Public scope.
>
> This property is read-only.
>
> This example checks the IsPublic property before taking an action.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   If prop.IsPublic Then
>     ' take an action here..
>   End If
> Next
> ```

<div id="propertyinfo.isshared">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.IsShared

**IsShared** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, it is a shared property and does not require a `Self</api/language/self_keyword>` parameter when called by `Introspection</api/language/introspection/introspection>`.
>
> This property is read-only.
>
> This example reports whether the properties for the `DateTime</api/data_types/datetime>` class are shared.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
> Var myProperties() As Introspection.PropertyInfo = Introspection.GetType(d).GetProperties
>
> For Each prop As Introspection.PropertyInfo In myProperties
>   If prop.CanRead Then
>     ListBox1.AddRow(prop.IsShared.ToString)
>   End If
> Next
> ```

<div id="propertyinfo.name">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.Name

**Name** As `String</api/data_types/string>`

> The name of the item. This is only the class name. To get the full namespace path, use FullName instead.
>
> This property is read-only.
>
> This code gets the list of properties for the passed type instance.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
>
> For Each prop As Introspection.PropertyInfo In Introspection.GetType(d).GetProperties
>   ListBox1.AddRow(prop.Name)
> Next
> ```

<div id="propertyinfo.propertytype">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.PropertyType

**PropertyType** As `TypeInfo</api/language/introspection/typeinfo>`

> Contains the property's datatype.
>
> This property is read-only.
>
> This example gets the data type of each property of the `DateTime</api/data_types/datetime>` class.
>
> ``` xojo
> Var d As DateTime = DateTime.Now
> Var myProperties() As Introspection.PropertyInfo = Introspection.GetType(d).GetProperties
>
> For Each prop As Introspection.PropertyInfo In myProperties
>   ListBox1.AddRow(prop.PropertyType.FullName)
> Next
> ```

## Method descriptions

<div id="propertyinfo.getattributes">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.GetAttributes

**GetAttributes** As `AttributeInfo()</api/language/introspection/attributeinfo>`

> Returns an array of `AttributeInfo</api/language/introspection/attributeinfo>` objects.
>
> The following gets the attributes of window1.
>
> ``` xojo
> Var myAttributes() As Introspection.AttributeInfo = Introspection.GetType(Window1).GetAttributes
> ```

<div id="propertyinfo.value">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

PropertyInfo.Value

**Value**(obj As `Object</api/data_types/additional_types/object>`) As `Variant</api/data_types/variant>`

> Returns the value of the property, given an instance of the property's class.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="rst-class">

forsearch

</div>

PropertyInfo.Value

**Value**(base As `Object</api/data_types/additional_types/object>`, `Assigns</api/language/assigns>` value As `Variant</api/data_types/variant>`)

> Sets the value of the property, given an instance of the property's class. If the property is shared, specify Nil for the *base* parameter.
>
> This example gets and then changes the value to its compacted version:
>
> ``` xojo
> Var json As New JSONItem
> Var myProperties() As Introspection.PropertyInfo = Introspection.GetType(json).GetProperties
>
> For Each p As Introspection.PropertyInfo In myProperties
>   Select Case p.Name
>   Case "Compact"
>     Var value As Boolean = p.Value(json)
>
>     MessageBox("Current Compact value = " + value.ToString)
>
>     ' Toggle Compact
>     p.Value(json) = Not value
>
>     MessageBox("New Compact value = " + json.Compact.ToString)
>   End Select
> Next
> ```
>
> To get an array property, you assign the value back to an array. This example uses a class (TestClass that has TestArray() As String with two values. It gets the array values:
>
> ``` xojo
> Var t As New TestClass
>
> Var ti As Introspection.TypeInfo
> ti = Introspection.GetType(t)
>
> Var p() As Introspection.PropertyInfo
> p = ti.GetProperties
>
> For Each pi As Introspection.PropertyInfo In p
>   Var pt As Introspection.TypeInfo
>   pt = pi.PropertyType
>
>   Select Case pi.Name
>   Case "TestArray"
>     If pt.IsArray Then
>       If pi.Value(t).ArrayElementType = 8 Then ' String
>         Var s() As String
>
>         s = pi.Value(t)
>
>         MessageBox("Array = (" + String.FromArray(s, ",") + ")")
>       End If
>     End If
>   End Select
> Next
> ```

## Sample code

This example gets the list of properties for the passed type instance.

``` xojo
Var d As DateTime = DateTime.Now
Var myProperties() As Introspection.PropertyInfo = Introspection.GetType(d).GetProperties
For Each prop As Introspection.PropertyInfo In myProperties
  ListBox1.AddRow(prop.Name)
Next
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`MemberInfo</api/language/introspection/memberinfo>` parent class; `Introspection</api/language/introspection/introspection>` module; `AttributeInfo</api/language/introspection/attributeinfo>`, `ConstructorInfo</api/language/introspection/constructorinfo>`, `MemberInfo</api/language/introspection/memberinfo>`, `MethodInfo</api/language/introspection/methodinfo>`, `ObjectIterator</api/language/introspection/objectiterator>`, `ParameterInfo</api/language/introspection/parameterinfo>`, `TypeInfo</api/language/introspection/typeinfo>` classes; `GetTypeInfo</api/language/introspection/gettypeinfo>` function.

</div>
