ReflectorGetProperty(Type, String, ReflectionWays) Method

Gets the static property of a Type represented by the specified propertyName.

Definition

Namespace: KGySoft.Reflection
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
public static Object? GetProperty(
	Type type,
	string propertyName,
	ReflectionWays way = ReflectionWays.Auto
)

Parameters

type  Type
The Type the static property belongs to.
propertyName  String
The name of the property to get.
way  ReflectionWays  (Optional)
The preferred reflection way. TypeDescriptor way is not applicable for static properties. This parameter is optional.
Default value: Auto.

Return Value

Object
The value of the property.

Remarks

propertyName can refer public and non-public properties.

If you already have a PropertyInfo instance use the GetProperty(Object, PropertyInfo, ReflectionWays, Object) method for better performance.

If you are not sure whether a property with the specified propertyName exists, then you can use the TryGetProperty methods instead.

If way is Auto, then this method uses the DynamicDelegate reflection way.

See Also