ToString method when using .Dump


Would it be possible to get a feature implemented in linqpad, where linqpad does not call .ToString() on the objects being dumped.

The reason for this that if you have implemented a ToString() method on a class you don't neccessary want it to be used when calling .Dump().

void Main()

var c = new ClassWithToString();


var c2 = new ClassWithoutToString();


public class ClassWithoutToString
public int MyProperty { get; set; }
public int MyProperty2 { get; set; }
public int MyProperty3 { get; set; }


public class ClassWithToString : ClassWithoutToString
public override string ToString()
return $@{MyProperty},


In this example the result for ClassWithToString in the dump window looks silly, since Dump calls ToString() as part of dumping.

Where for the ClassWithoutToString looks as "expected" - where it just uses the name of the class.

Thanks in advance


  • You could customize Dump with ToDump in MyExtensions to avoid ToString:
    static object ToDump(object obj) {
            if (obj.GetType().GetMethod("ToString") != null)
                  return Util.ToExpando(obj);
                  return obj;
    Though you may want to restrict it to your own types.

    Also, you could add ToDump to your own classes:
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!