Answer by Mentoliptus · Nov 25, 2016 at 10:49 PM
It depends on what the array contains. If it is a primitive type (e.g. int, float) its easy:
var array = array.Where(val => val != valToRemove).ToArray();
If it is some complex type that doesn't implement an equality comparator you should compare by the value you need
var array = array.Where(val => val.SomeProperty != valToRemove).ToArray();
EDIT AFTER COMMENT
=> is called Lambda operator (and I can understand if you don't know about it), but != is the Inequality operator and its one of the most basic operators in any programming language.
Not to waste time explaining basics, here is an example for an array of integers:
int[] numbers = { 1, 3, 4, 9, 2 };
int numToRemove = 4;
numbers = numbers.Where(val => val != numToRemove).ToArray();
And an example for an array of Vector3 objects:
Vector3[] vectors = { new Vector3(1,1,1), new Vector3(3,3,3), new Vector3(4,4,4) };
Vector3 vectorToRemove = new Vector3(3,3,3);
vectors = vectors.Where(val => val != vectorToRemove).ToArray();
Answer by maio2002 · Nov 26, 2016 at 12:34 PM
Thx for the answer! :), I don´t understand how to make this code. Could you explain me how this work (I dont know what <= and != are doing)? It would be nice if you give an example how to do this with vector3s (or intergers).