title: Comparing array elements in C#
body: <p>two arraya namely <code>item</code> and <code>tra</code></p>
  
  <p><code>item</code> contains </p>
  
  <pre><code>B
  C
  M
  G
  D
  E
  </code></pre>
  
  <p><code>tra</code> array contains</p>
  
  <pre><code>BM
  BDGE
  MDGC
  BMDG
  BMDC
  </code></pre>
  
  <p>I need to find the count of each element in <code>item</code> array that is present in <code>tra</code> array</p>
  
  <p>for e.g. <code>B</code> count is 4 <code>C</code> count is 2</p>
  
  <p>for this task I make use of <code>count()</code> and counter variable.</p>
  
  <p>here is my code</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  namespace apriori
  {
      class apriori
      {
          static void Main(string[] args)
          {
              int t, n, s, i, j, k, q;
              int counter = 0;
              int[] count = new int[6];
  
              Console.WriteLine("enter the number of transactions t");
  
              t = Convert.ToInt32(Console.ReadLine());
  
              Console.WriteLine("enter the number of items n");
  
              n = Convert.ToInt32(Console.ReadLine());
  
              Console.WriteLine("enter minimum support s");
  
              s = Convert.ToInt32(Console.ReadLine());
  
              String[] tra = new String[t];
              String[] item = new String[n];
  
              Console.WriteLine("enter transactions representing one alphabet each item");
  
              for (i = 0; i &lt; t; i++)
              {
                  tra[i] = Console.ReadLine();
              }
  
              Console.WriteLine("list of transactions");
  
              foreach (String it in tra)
              {
                  Console.WriteLine(it);
              }
  
              Console.WriteLine("enter items");
  
              for (j = 0; j &lt; n; j++)
              {
                  item[j] = Console.ReadLine();
              }
  
              Console.WriteLine("list of items");
  
              foreach (String ite in item)
              {
                  Console.WriteLine(ite);
              }
  
              for (i = 0; i &lt; n; i++)
              {
                 for (j = 0; j &lt; t; j++)
                  {
                      if (item[i]==tra[j])
                      {
                        count[i]=counter++;
                      }
                  } 
  
                  counter=0;
              }
  </code></pre>