Advertisement
elena1234

How to remove a given element from array

Dec 4th, 2021 (edited)
1,672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.31 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement