Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to empty the Array in C#?

Tags:

arrays

c#

I am using the function Array.Clear() to empty an array, but it generates an error. This is the code I was using:

private int[] activeFielderNumber = new int[10];
private string[] activeFielderAction = new string[10];  
....
...
....
Array.Clear(activeFielderNumber, 0, activeFielderNumber.Length);
Array.Clear(activeFielderAction, "", activeFielderAction.Length);

The error is:

error CS0103: The name `Array' does not exist in the current context

How can I solve this problem?

like image 901
Ethan Avatar asked Dec 07 '12 05:12

Ethan


1 Answers

Try this

Array.Clear(yourArray, 0, yourArray.Length);
like image 132
Manoj Avatar answered Oct 13 '22 00:10

Manoj