How to clear array in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        int[] arr = { 1, 2, 3, 6, 0, -5, -4, 7, 9 };
        
        Array.Clear(arr, 0, arr.Length);

        Console.WriteLine(string.Join(" ", arr));
    }
}



/*
run:

0 0 0 0 0 0 0 0 0

*/

 



answered Sep 19, 2023 by avibootz

Related questions

...