Mono Class Library: System.Type Overview | Members

System.Type.GetProperty Method

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

public System.Reflection.PropertyInfo GetProperty (string name, System.Reflection.BindingFlags bindingAttr)

Parameters

name
A string containing the name of the property to be returned.
bindingAttr
A bitwise combination of System.Reflection.BindingFlags values that control the binding process. If zero is specified, this method returns null .

Returns

A System.Reflection.PropertyInfo object reflecting the property defined in the type represented by the current instance that matches the specified criteria. If no matching property is found, returns null . If the type reflected by the current instance is contained in a loaded assembly, the property that matches the specified criteria is not public, and the caller does not have sufficient permission, returns null.

Permissions

TypeReason
System.Security.Permissions.ReflectionPermissionRequires permission to retrieve information on non-public members of types in loaded assemblies. See System.Security.Permissions.ReflectionPermissionFlag.TypeInformation.

Exceptions

TypeReason
System.Reflection.AmbiguousMatchExceptionMore than one property matching the specified criteria was found.
ArgumentNullExceptionname is null.

Remarks

The following System.Reflection.BindingFlags are used to define which members to include in the search:

The following System.Reflection.BindingFlags values can be used to change how the search works:

Note: For more information, see System.Reflection.BindingFlags.

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, bindingAttr, null, null, null, null).

The search for name is case-sensitive.

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