MemberInfo.GetCustomAttributes extensions overload

Viewed 1889

I noticed there are two methods (one class method and one extension method) with the same signature but different return types in package System.Reflection for class MemberInfo:

Class method:

public abstract object[] GetCustomAttributes(Type attributeType, bool inherit)

Extension method (inside CustomAttributeExtensions):

public static IEnumerable<Attribute> GetCustomAttributes(this MemberInfo element, Type attributeType, bool inherit)

I know that calling that method with such parameters will always invoke class method, so I am just wondering:

how to call extension method?

and, above all, what's the purpose of defining an extension with same signature as class method?

2 Answers
Related