title: Checked checkboxes to comma separated list with word "and" at the end in C#
body: <p>I'm have a few checkboxes nestled inside a WinForms panel. When the checkboxes are checked, I want to create a comma separated list, but with the word "and" before the last checkbox text value.</p>
  
  <p>Here is the code I currently have...which is executed from a single event handler shared by all checkboxes:</p>
  
  <pre><code>    string checkboxes = " ";
      foreach (Control c in MyPanel.Controls)
      {
          if (c is CheckBox &amp;&amp; (c as CheckBox).Checked)
              checkboxes += (c as CheckBox).Text;
      }
      checkboxes = string.Join(", ", checkboxes.Take(checkboxes.Count() - 1)) + (checkboxes.Count() &gt; 1 ? " and " : "") + checkboxes.LastOrDefault();
      Console.WriteLine(checkboxes + "are checked");
  </code></pre>
  
  <p>I have the following checkboxes:</p>
  
  <pre><code>_Item A
  _Item B
  _Item C
  _Item D
  </code></pre>
  
  <p>If, for example, Item A and B are checked, I want it to spit out "<strong>Item A and B are checked</strong>".</p>
  
  <p>If Item A, B and D are checked... "<strong>Item A, Item B and Item D are checked</strong>"</p>
  
  <p>However, with my current code, it's doing something similar to this:</p>
  
  <blockquote>
    <p>, I, t, e, m, A, I, t, e, m, B, I, t, e, m and D are checked.</p>
  </blockquote>
  
  <p>If someone could point me into the right direction, I'd much appreciate it!</p>