elena1234

How to remove a given element from array

Dec 4th, 2021 (edited)
1,432
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Linq;
  2. using System;
  3.  
  4. namespace Remove
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] numbers = { 1, 3, 4, 9, 2 };
  11.             int numToRemove = 4;
  12.             numbers = numbers.Where(val => val != numToRemove).ToArray();
  13.         }
  14.     }
  15. }
  16.  
RAW Paste Data