I have code that I want to make the following changes:
How do I override ToString()? It says: A static member ...ToString(System.Collections.Generic.List)\'
If you want to override ToString()
, you would need to inherit from List
rather than try to extend it. You have already seen that you cannot mark the static extension method as override, and overload resolution will always go for the member method over an extension method if it is available. Your options are
ToSpecialString()
MyExtensions.ToString(myList);