title: Remove second occurrence of value from array C#
body: <p>Instead of removing the first occurrence of a duplicated value, as my code currently does, how can I get it to delete the second occurrence instead?</p>
  <pre><code>namespace deletenumber
  {
      class Program
      {    
          public static void Main(String[] args)
          {
  
              Random r = new Random();
  
              int[] a = new int[10];
  
              for (int i = 0; i &lt; 10; i++)
                  a[i] = r.Next(1, 100);
  
              for (int i = 0; i &lt; 10; i++)
                  Console.WriteLine(&quot; a [&quot; + i + &quot;] = &quot; + a[i]);
  
              Console.WriteLine();
              Console.ReadLine();
  
              Console.WriteLine(&quot;What number do you want to delete?&quot;);
              int item = Convert.ToInt32(Console.ReadLine());
              Console.WriteLine();
  
              int index = Array.IndexOf(a, item);
              a = a.Where((b, c) =&gt; c != index).ToArray();
  
              Console.WriteLine(String.Join(&quot;, &quot;, a));
              Console.ReadLine();
          }
      }
  }
  </code></pre>