Your first problem is a syntax error: new Queue<int>[8]()
should be new Queue<int>[8]
.
Once declared with the correct syntax, when you attempt to use an element of the array (downBoolArray[0].Enqueue(1)
) you will encounter a NullReferenceException because array elements initialise to their default values which in the case of a reference type is null
.
You could instead initialise your array with non-null seed values using a single line of LINQ:
Queue<int>[] downBoolArray = Enumerable.Range(1,8).Select(i => new Queue<int>()).ToArray();
The arguments to Range
specify that we need 8 'entries' in our sequence; the Select
statement creates a new Queue<int>
for each item; and the ToArray
call outputs our sequence as an array.