title: Find the count of duplicate items in a C# List
body: <p>I am using List in C#. Code is as mentioned below:</p>
  
  <p>TestCase.cs</p>
  
  <pre><code> public class TestCase
  {
      private string scenarioID;
      private string error;
  
      public string ScenarioID
      {
          get
          {
              return this.scenarioID;
          }
          set
          {
              this.scenarioID = value;
          }
      }
  
      public string Error
      {
          get
          {
              return this.error;
          }
          set
          {
              this.error = value;
          }
      }
  
      public TestCase(string arg_scenarioName, string arg_error)
      {
          this.ScenarioID = arg_scenarioName;
          this.Error = arg_error;
      }
  }
  </code></pre>
  
  <p>List I am createing is:</p>
  
  <pre><code>private List&lt;TestCase&gt; GetTestCases()
      {
          List&lt;TestCase&gt; scenarios = new List&lt;TestCase&gt;();
          TestCase scenario1 = new TestCase("Scenario1", string.Empty);
          TestCase scenario2 = new TestCase("Scenario2", string.Empty);
          TestCase scenario3 = new TestCase("Scenario1", string.Empty);
          TestCase scenario4 = new TestCase("Scenario4", string.Empty);
          TestCase scenario5 = new TestCase("Scenario1", string.Empty);
          TestCase scenario6 = new TestCase("Scenario6", string.Empty);
          TestCase scenario7 = new TestCase("Scenario7", string.Empty);
  
          scenarios.Add(scenario1);
          scenarios.Add(scenario2);
          scenarios.Add(scenario3);
          scenarios.Add(scenario4);
          scenarios.Add(scenario5);
          scenarios.Add(scenario6);
          scenarios.Add(scenario7);
  
          return scenarios;
      }
  </code></pre>
  
  <p>Now I am iterating through the list. I want to find the how many duplicate testcases are there in a list with same ScenarioID. Is there any way to solve it using Linq or any inbuilt method for List?</p>
  
  <p>Regards,
  Priyank</p>