Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
PropertyType Property

PropertyInfo.PropertyType Property

Gets the type of this property.

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

abstract PropertyType : Type with get

Property Value

Type: System.Type
The type of this property.

To determine the type of a particular property, do the following:

  1. Get a Type object that represents the type (the class or structure) that contains the property. If you are working with an object (an instance of a type), you can call its GetType method. Otherwise, you can use the C# typeof operator or the Visual Basic GetType operator, as the example illustrates.

  2. Get a PropertyInfo object that represents the property in which you're interested. You can do this by getting an array of all properties from the Type.GetProperties method and then iterating the elements in the array, or you can retrieve the PropertyInfo object that represents the property directly by calling the Type.GetProperty method and specifying the property name.

  3. Retrieve the value of the PropertyType property from the PropertyInfo object.

The following example defines an Employee class that has five properties. It then uses retrieves an array of PropertyInfo objects that represent those properties and displays the name and type of each.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft