Hey all,
There are two ways I know of to increase the usefulness of debugging information so you don't see {MyNamespace.MyProject.MyClass} in the debugger. These are the use of the DebuggerDisplay attribute and the ToString method.
[DebuggerDisplay("Name = {Name}")]
public class Person
{
public string Name;
}
or
public class Person
{
public string Name;
public override string ToString()
{
return string.Format("Name = {0}", Name);
}
}
Is there any reason to prefer one to the other? Any reason not to do both? Is it purely personal preference?