title: C# .NET email client alternate tr row colors based on even / odd
body: <p>Trying to get the  color to alternate colors based on even / odd in c# using inline css</p>
  
  <pre><code> sb.AppendLine("&lt;table width='100%' border='0' align='center' cellpadding='5' cellspacing='0' style='font-family:arial,helvetica,sans-serif;'&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style='padding:5px;background-color:rgb(169, 169, 169);color:white;'&gt;Filenames&lt;/td&gt;&lt;/tr&gt;");
   foreach (var item in logList)
   {
      sb.AppendLine("&lt;tr&gt;&lt;td style='background-color:#55bada;'&gt;" + Path.GetFileName(item) + "&lt;/td&gt;&lt;/tr&gt;");
      sb.Append("&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;");
   }
  </code></pre>
  
  <p>I have tried the following but it seems to duplicate the data and not shift the coloring evenly</p>
  
  <pre><code>sb.AppendLine("&lt;table width='100%' border='0' align='center' cellpadding='5' cellspacing='0' style='font-family:arial,helvetica,sans-serif;'&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style='padding:5px;background-color:rgb(169, 169, 169);color:white;'&gt;Filenames&lt;/td&gt;&lt;/tr&gt;");
  int count = 0;
  foreach (var item in logList)
  {
     for (count = 0; count &lt;= logList.Count; count ++)
     {
        if (count % 2 == 0)
        {
          count += 1;
          sb.AppendLine("&lt;tr&gt;&lt;td style='background-color:#bada55;'&gt;" + Path.GetFileName(item) + "&lt;/td&gt;&lt;/tr&gt;");
  
        }
        else
        {
           count -= 1;
           sb.AppendLine("&lt;tr&gt;&lt;td style='background-color:#55bada;'&gt;" + Path.GetFileName(item) + "&lt;/td&gt;&lt;/tr&gt;");
        }
     }
  }
  sb.Append("&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;");
  </code></pre>
  
  <p><a href="http://cc.davelozinski.com/c-sharp/fastest-way-to-check-if-a-number-is-odd-or-even" rel="nofollow noreferrer">Check Even Odd</a>
  <img src="https://i.stack.imgur.com/JEJzM.png" alt="Wrong"></p>