title: How to count lines in a string?
body: <p><strong>I am removing text from a string and what to replace each line with a blank line.</strong></p>
  
  <p><em><strong>Some background:</em></strong>
  I am writing a compare function that compares two strings. Its all working fine and are displayed in there two separate web browsers. When i try scroll down on my browsers the strings are different lengths, I want to replace the text i am removeing with a blank line so that my strings are the same length.</p>
  
  <p><strong>In the code below i am looking to count how many lines aDiff.Text has</strong></p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>public string diff_prettyHtmlShowInserts(List&lt;Diff&gt; diffs)
      {
          StringBuilder html = new StringBuilder();
  
          foreach (Diff aDiff in diffs)
          {
              string text = aDiff.text.Replace("&amp;", "&amp;amp;").Replace("&lt;", "&amp;lt;")
                .Replace("&gt;", "&amp;gt;").Replace("\n", "&lt;br&gt;"); //&amp;para;
              switch (aDiff.operation)
              {
  
                  case Operation.DELETE:                              
                     //foreach('\n' in aDiff.text)
                     // {
                     //     html.Append("\n"); // Would like to replace each line with a blankline
                     // }
                      break;
                  case Operation.EQUAL:
                      html.Append("&lt;span&gt;").Append(text).Append("&lt;/span&gt;");
                      break;
                  case Operation.INSERT:
                      html.Append("&lt;ins style=\"background:#e6ffe6;\"&gt;").Append(text)
                          .Append("&lt;/ins&gt;");
                      break;
              }
          }
          return html.ToString();
      }
  </code></pre>