remove element from array | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

remove element from array

I can not for the life of me remember how to remove an element from an array in c# I know its simple but I cant remember any help would be great

9th Sep 2018, 8:46 PM
David Aseltine
David Aseltine - avatar
5 ответов
+ 3
hinanawi Resize is just one of many ways to a replace with a new array.
10th Sep 2018, 3:03 PM
John Wells
John Wells - avatar
+ 2
Arrays in C# can not change size. Use Lists or replace with a new array.
9th Sep 2018, 10:56 PM
John Wells
John Wells - avatar
+ 1
John Wells well you can use Array.Resize() to create a new array of a different length and replace the old array with that one, but it is beyond inefficient
10th Sep 2018, 9:10 AM
hinanawi
hinanawi - avatar
+ 1
I think you should use dynamic container classes eg. vector, list etc. which has erase member function.
10th Sep 2018, 12:31 PM
Károly Komjáti
Károly Komjáti - avatar