Why we should use ToString method with StringBuilder?

c#, string, stringbuilder, tostring

Solution

These two calls use different `Console.WriteLine` overloads: `WriteLine(Object)` and `WriteLine(String)`.

And the `WriteLine(object)` overload calls "... the ToString method of value is called to produce its string representation, and the resulting string is written to the standard output stream." (msdn)

Edit

The only difference here I can see is:

StringBuilder sb = null;
Console.WriteLine(sb); // prints terminator
Console.WriteLine(sb.ToString()); // throws NullReferenceException

Problem

MSDN says we need to convert `StringBuilder` object to `string`, but `StringBuilder` works fine? Why should we convert? ``` string[] spellings = { "hi", "hiii", "hiae" }; StringBuilder Builder = new StringBuilder(); int counter = 1; foreach (string value in spellings) { Builder.AppendFormat("({0}) Which is Right spelling? {1}", counter, value); Builder.AppendLine(); counter++; } Console.WriteLine(Builder); // Works Perfectly //Why should i use tostring like below Console.WriteLine(Builder.ToString()); // Does it make any difference in above two ways. Console.ReadLine(); ```

Original source