I am making the following call to an extension method:
database.ExecuteScalar(command).NoNull<string>(string.Empty);
I get an error that the extension method is ambiguous .
I have two dlls with the same code that implement NoNull(string str)
under different namespaces.
How can I explicitly refer to one namespace?
How would I have it done if it was the same namespace?
Update: I cannot rewrite the 3rd party dlls.
Ambiguity can be resolved if concurrent namespaces which have extension methods with same name, are included at different levels (most inner included namespace will have priority).
Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are static methods, but they're called as if they were instance methods on the extended type.
In object-oriented computer programming, an extension method is a method added to an object after the original object was compiled. The modified object is often a class, a prototype or a type. Extension methods are features of some object-oriented programming languages.
An extension method allows you to add functionality to an existing type without modifying the original type or creating a derived type (and without needing to recompile the code containing the type that is extended.)
using
directive. Abc.Xyz.ExtensionsClass.NoNull(database.ExecuteScalar(), string.Empty); // <Abc.Xyz.> is only necessary if the classes themselves match names // if not, only <ClassName>.<MethodName> is needed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With