How to call an extension method without using
c#
Solution
It is possible to directly call your extension like so since it is simply a static method, passing the instance it will act on as the first `this` parameter:
A a = new A();
ExtensionMethod.AExtensions.PrintStuff(a);
This might be confusing to other developers who happen across this code if you followed this pattern for more commonly used extension methods. It would also make chaining extension calls such as LINQ appear more like a functional language because you would be nesting each call instead of chaining them.
Problem
``` using System; class Runner { static void Main() { A a = new A(); // how to say a.PrintStuff() without a 'using' Console.Read(); } } class A { } namespace ExtensionMethod { static class AExtensions { public static void PrintStuff(this A a) { Console.WriteLine("text"); } } } ``` How would I call the extension method without a 'using'? And not ExtensionMethod.AExtensions.PrintStuff(a), since that doesn't make use of extension method.