Mono Class Library: System.Type Overview | Members

System.Type.GetProperty Method

Returns a System.Reflection.PropertyInfo object that reflects the public property defined in the type represented by the current instance that matches the specified search criteria.

public System.Reflection.PropertyInfo GetProperty (string name, Type returnType, Type[] types)

Parameters

name
A string containing the name of the public property to be returned.
returnType
A Type object that represents the type of the public property to be returned.
types
An array of Type objects. The elements in the array are of the same number, in the same order, and represent the same types as the parameters for the indexer to be returned. Specify Type.EmptyTypes for a property that is not indexed.
returnType
Documentation for this section has not yet been entered.

Returns

A System.Reflection.PropertyInfo object reflecting the public property defined in the type represented by the current instance that matches the specified criteria. If no matching property is found, returns null .

Exceptions

TypeReason
System.Reflection.AmbiguousMatchExceptionMore than one property matching the specified criteria was found.
ArgumentNullExceptionname or types is null, or at least one of the elements in types is null.
ArgumentExceptiontypes has more than one dimension.

Remarks

This version of Type.GetProperty(string, System.Reflection.BindingFlags, System.Reflection.Binder, Type, Type[], System.Reflection.ParameterModifier[]) is equivalent to Type.GetPropertyImpl(string, System.Reflection.BindingFlags, System.Reflection.Binder, Type, Type[], System.Reflection.ParameterModifier[])(name, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, null, returnTypes, types, null).

The search for name is case-sensitive.

Different programming languages use different syntax to specify indexed properties. Internally, this property is referred to by the name "Item" in the metadata. Therefore, any attempt to retrieve an indexed property using reflection is required to specify this internal name in order for the PropertyInfo to be returned correctly.

If the current instance represents a generic type, this method returns the System.Reflection.PropertyInfo with the type parameters replaced by the appropriate type arguments.

If the current instance represents an unassigned type parameter of a generic type or method, this method searches the properties of the class constraint; the properties of all interface constraints; and the properties of any interfaces inherited from class or interface constraints.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0