Click or drag to resize

TypeExtensionsGetPropertyExtended Method

Gets the property from the type or base types.

Note: Type.GetProperty only looks at the actual type.

Read our blog on this topic: Effective Extensions – Extending Types in C#

Namespace:  Xcalibur.Extensions
Assembly:  Xcalibur.Extensions (in Xcalibur.Extensions.dll) Version: 1.0.4.0 (1.0.0.0)
Syntax
public static PropertyInfo GetPropertyExtended(
	this Type type,
	string propertyName
)

Parameters

type
Type: SystemType
The type.
propertyName
Type: SystemString
Name of the property.

Return Value

Type: PropertyInfo

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Type. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Examples
C#
 1internal string GetPropertyExtendedExample<T>()
 2{
 3    // Search properties
 4    const string propertyName = "PropertyName";
 5
 6    // Get property
 7    var property = typeof(T).GetPropertyExtended(propertyName);
 8    return property != null 
 9        ? "That property exists!" 
10        : "That property does not exist!";
11}
See Also