Open sandboxFocus

Method GetAutomaticProperty

GetAutomaticProperty(FieldInfo)

Gets the PropertyInfo of which a given field is the backing field, in the current type or its base types.

Declaration
[RequiresUnreferencedCode("Finds the property by name in the declaring type of the field, and trimming can remove the property.")]
public static PropertyInfo GetAutomaticProperty(this FieldInfo field)
Parameters
Type Name Description
FieldInfo field

A field.

Returns
Type Description
PropertyInfo

The PropertyInfo representing the property whose field is the backing field, or null if field is not the backing field of an automatic property.

GetAutomaticProperty(FieldInfo, bool)

Gets the PropertyInfo of which a given field is the backing field. The inherit parameter specifies whether base types should be considered.

Declaration
[RequiresUnreferencedCode("Finds the property by name in the declaring type of the field, and trimming can remove the property.")]
public static PropertyInfo GetAutomaticProperty(this FieldInfo field, bool inherit)
Parameters
Type Name Description
FieldInfo field

A field.

bool inherit

true if the property should be looked for in the base types, otherwise false.

Returns
Type Description
PropertyInfo

The PropertyInfo representing the property whose field is the backing field, or null if field is not the backing field of an automatic property.