title: Apriori in C# - Error: Index was out of range
body: <p>My soluton here: <a href="http://www.mediafire.com/?rzrhvc71musz793" rel="nofollow">http://www.mediafire.com/?rzrhvc71musz793</a>
  <br>
  I get error "Additional information: Index was out of range. Must be non-negative and less than the size of the collection" in line 238 file Apriori.cs</p>
  
  <pre><code>private List&lt;Rule&gt; GenerateRules()
  {
      var rules = new List&lt;Rule&gt;();
  
      foreach (var item in _allFrequentItems)
      {
          if (item.val.Count &gt; 1)
          {
              int maxCombinationLength = item.val.Count / 2;
              GenerateCombination(item.val, maxCombinationLength, ref rules);
          }
      }
  
      return rules;
  }
  private void GenerateCombination(List&lt;int&gt; item, int combinationLength, ref List&lt;Rule&gt; rules)
  {
      int itemLength = item.Count;
  
      switch (itemLength)
      {
          case 2:
              AddItem(new List&lt;int&gt;(){item[0]}, item, ref rules);
              break;
          case 3:
              for (int i = 0; i &lt; itemLength; i++)
              {
                  AddItem(new List&lt;int&gt;{item[i]}, item, ref rules);
              }
              break;
          default:
              for (int i = 0; i &lt; itemLength; i++)
              {
                  GetCombinationRecursive(new List&lt;int&gt;() { item[i] }, item, combinationLength, ref rules);
              }
              break;
      }
  }
  </code></pre>
  
  <p>In GenerateRules() i have check item.val.Count>1 and in GenerateCombination itemLength = item.Count..Why in my debug item.Count =1 , itemLength =3????</p>