How to create an extension method for ToString?

Extension methods are only checked if there are no applicable candidate methods that match. In the case of a call to ToString() there will always be an applicable candidate method, namely, the ToString() on object. The purpose of extension methods is to extend the set of methods available on a type, not to override existing methods; that’s why they’re called “extension methods”. If you want to override an existing method then you’ll have to make an overriding method.

Leave a Comment