Translate Blog

26 Nisan 2020 Pazar

Unity C# Dizi Sıfırlama / How to reset array on C# or destroy all elements of array

I could not find any array reset code. An here is my code to remove all elements of an array. It will destroy all the childs of an array.



int [] emptyarray = {};
int [] myarray = new int[] { 7, 0, 6, 0, 7, 1, 6, 1, 7, 2, 6, 2, 7, 3, 6, 3, 7, 4, 6, 4, 7, 5, 6, 5, 7 };

this will do the magic

myarray = emptyarray.ToArray();

Your array now empty like new created.