PropertyType Property
Collapse the table of content
Expand the table of content

PropertyInfo.PropertyType Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the type of this property.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public MustOverride ReadOnly Property PropertyType As Type

Property Value

Type: System.Type
The type of this property.

The Type is String, Boolean, Int32, and so on.

To get the PropertyType property, first get the class Type. From the Type, get the PropertyInfo. From the PropertyInfo, get the PropertyType value.

The following example displays the type of a property.


Imports System.Reflection

Public Class Example
    Public ReadOnly Property Answer() As Integer
        Get
            Return 42
        End Get
    End Property

    Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
        ' Get a Type object for the Example type.
        Dim t As Type = GetType(Example)

        ' Get a PropertyInfo object for the Answer property.
        Dim pi As PropertyInfo = t.GetProperty("Answer")

        ' Display the type returned by the Answer property.
        outputBlock.Text &= String.Format("The return type of the {0}.{1} property is {2}.", _
             t.Name, pi.Name, pi.PropertyType) & vbCrLf

    End Sub
End Class

' This example produces the following output:
'
'The return type of the Example.Answer property is System.Int32.


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft