title: Stringbuilder add new line inside foreach loop
body: <p>I'm trying to add a <code>new line</code> after looping through the group names inside of a <code>foreach</code> loop. However, it never adds the new line. Everything is printed in single line.</p>
  
  <pre><code>string [] groups = client.GetGroups(username.TrimEnd());
  
  StringBuilder groupNames = new StringBuilder();
  
  foreach (string groupName in groups)
  {
     groupNames.Append(string.Format(groupName,Environment.NewLine));
  }
  
  Label1.Text = groupNames.ToString();
  </code></pre>
  
  <p>After reading few questions posted here in SO, I have tried many different solutions such as:</p>
  
  <pre><code>{
     groupNames.Append(groupName);
     groupNames.AppendLine();
  }
  Label1.Text = groupNames.ToString();    
  </code></pre>
  
  <p>Also tried:</p>
  
  <pre><code>{ 
     groupNames.Append(groupName);
     groupNames.Append(System.Environment.NewLine);
  }
  Label1.Text = groupNames.ToString();
  </code></pre>
  
  <p>However, if in any of the solution I add:</p>
  
  <pre><code>groupNames.Append("|");
  //or
  groupNames.Append(",");
  </code></pre>
  
  <p>it will work. The only thing is not working is the <code>newline</code>. </p>
  
  <p>One thing to note is I'm grabbing the users <code>groupNames</code> from <code>Active Directory</code> and when the <code>groupNames</code> returned it contains <code>\</code> in the name. I also tried removing the <code>\</code> before adding new line, didn't work either.</p>
  
  <pre><code>groupNames.Append(groupName);
  groupNames.Replace(@"\", " ");
  groupNames.Append(System.Environment.NewLine);
  </code></pre>
  
  <p>Any suggestions?</p>