c# - How to call an extension method without using -
using system; class runner { static void main() { a = new a(); // how a.printstuff() without 'using' console.read(); } } class { } namespace extensionmethod { static class aextensions { public static void printstuff(this a) { console.writeline("text"); } } } how call extension method without 'using'? , not extensionmethod.aextensions.printstuff(a), since doesn't make use of extension method.
that possible if extension method , class in same namespace,
if have use different namespaces have use using, don't think there way without using. may reduce number of using putting extensions in 1 namespace linq (system.linq.extensions)
note : can remove namespace extension methods, make them globally available
Comments
Post a Comment