title: Unique values in a C# List
body: <p>I was using MVC3 with Entity framework. This time I wanted to make unique items in list. Here is my list of items.</p>
  
  <p><strong>List</strong></p>
  
  <pre><code>1.Overdue-1
  2.Overdue-M
  3.ItemsDue-1
  4.ItemsDue-5
  </code></pre>
  
  <p>Among the above list, I just wanted to filter to get only this list,</p>
  
  <pre><code>1.Overdue
  2.Itemsdue
  </code></pre>
  
  <p>Also, I need to make this one as DropdownList where Overdue or Itemsdue as Dropdown Text field &amp; 1 to n as Value field. I have tried this one. But I could do the logic for Dropdown and Unique list.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>var select = (from asd in db.Sys
                        select new EmailTemp
                        {
                            SysCode = asd.Code,
                            SysmailId = asd.Id
                        }).Distinct().ToList();
          List&lt;EmailTemp&gt; filterlist = new List&lt;EmailTemp&gt;();
          foreach (var a in select)
          {
              string lates = a.SysCode;
              var ind = lates.IndexOf("-");
              if (ind &gt; 0)
              {
                  a.SysCode = lates.Substring(0, ind);
                  a.SysmailId = a.SysmailId;
                  filterlist.Add(a);
              }
              else
              {
                  a.SysCode = lates;
                  a.SysmailId = a.SysmailId;
                  filterlist.Add(a);
              }
          }
          //var idlist = filterlist.Distinct().ToList();
          ViewBag.SysMailType = new SelectList(filterlist.Distinct().ToList(), "SysmailId", "SysCode");
  </code></pre>
  
  <p>Pls anyone tell me the possibilities that i can write down the code to achieve my logic.</p>
  
  <p>Thanks</p>