This incomplete program is given in the following website:
http://www.dotnetperls.com/stringbuilder
What is the meaning of "Get a reference to the StringBuilder's buffer content."
And what is use of Debug.WriteLine(innerString);.
Problem is highlighted
using System;
using System.Text;
using System.Diagnostics;
class Program
{
static void Main()
{
// 1.
// Declare a new StringBuilder.
StringBuilder builder = new StringBuilder();
// 2.
builder.Append("The list starts here:");
// 3.
builder.AppendLine();
// 4.
builder.Append("1 cat").AppendLine();
// 5.
// Get a reference to the StringBuilder's buffer content.
string innerString = builder.ToString();
// Display with Debug.
Debug.WriteLine(innerString);
Console.ReadKey();
}
Loading
VulpesPosted Jul 18, 2013, 10:19 AM
Make sure that the ComboBox at the top of the Output window is showing output from Debug rather than Build.
The output from Debug.WriteLine should show up in this window.
Posted Jul 18, 2013, 10:48 AM
Posted Jul 18, 2013, 10:00 AM
VulpesPosted Jul 18, 2013, 8:41 AM
Internally, the StringBuilder class maintains a buffer which contains the current characters. This buffer is automatically increased in size if more characters are added than can currently be accommodated.
It's always possible to get a string representation of this buffer by calling the StringBuilder's ToString() method which is what this program is doing.
Instead of writing this string to the console, Debug.WriteLine() writes its contents to the debugger's output window in Visual Studio.