According to Microsoft, "extension methods are a special type of static method, but they are invoked as if they were instance methods of an extended type."
Yes, extension methods are static methods. All of them can be called in the usual way as static methods, such as extension instance methods for the type that they "extend", and they can even be called extension methods for null reference.
For instance:
public static class Extensions { public static bool IsNullOrEmpty(this string theString) { return string.IsNullOrEmpty(theString); } }
Edit:
Is there a way to add an extension method that it called, as if it were a static method?
Do you want you to call e.g. string.MyExtensionMethod ()? In this case, no, there is no way to do this.
source share