Continuing in our weekly blog post series that highlights a few of the new additions to the Framework Design Guidelines 2nd edition.. This content is found in the Object.ToString section of Chapter 8: Usage Guidelines. Christophe provides some great implementation tips for these guidelines.
DO try to keep the string returned from ToString short.
The debugger uses ToString to get a textual representation of an object to be shown to the developer. If the string is longer than the debugger can display (typically less than one screen length), the debugging experience is hindered.
In term of debugging experience, you should decorate your type with DebuggerDisplayAttribute in addition to overriding ToString for that particular purpose.
DO string formatting based on the current thread culture when returning culture-dependent information.
To be more explicit, use the CultureInfo instance returned by a thread’s CurrentCulture property to format any numeric or date, and the one returned by CurrentUICulture to look up any resource. People are often confused between the two properties.