I would like to determine if a parameter has this
modifier using Reflection
.I have looked at properties of ParameterInfo
class, but couldn't find anything useful.I know the extension methods are just syntactic sugars but I believe there should be a way to determine whether a method is an extension method.
The only thing that distinguishes extension methods from other static methods (that are defined in a static, public class) is this
modifier.
For example this is not an extension method:
public static int Square(int x) { return x * x; }
But this is:
public static int Square(this int x) { return x * x; }
So how can I distinguish between two methods using Reflection
or something else if possible?