I want to override ToString()
on IEnumerable<Int32>
.
I was thinking to use Extension methods.
But when I do this below, it still calls the ToString()
on System.Object
. When I rename my method, then it calls my method.
As my extension method is in a static class, I am not able to override.
How can I achieve this so that my ToString()
implementation is called when I call .ToString()
on List<Int32>
for example?
public static class ExtensionMethods
{
public static new string ToString(this IEnumerable<Int32> set)
{
var sb = new StringBuilder();
// Do some modifications on sb
return sb.ToString();
}
}