C# syntax for array of Queue

I cannot find syntax for arrays of Queue!  All variations I have tried
seem to be rejected by the compiler in VS2008.
Perhaps someone can give me an answer to this?
Currently I have made the Queues separate as shown below:

        // this form does not seem to accept an argument for initial capacity!
        public Queue<double> firstQueue0 = new Queue<double>();
        public Queue<double> firstQueue1 = new Queue<double>();
        public Queue<double> firstQueue2 = new Queue<double>();
        public Queue<double> firstQueue3 = new Queue<double>();
        public Queue<double> firstQueue4 = new Queue<double>();
        public Queue<double> firstQueue5 = new Queue<double>();
        public Queue<double> firstQueue6 = new Queue<double>();
        public Queue<double> firstQueue7 = new Queue<double>();
        public Queue<double> firstQueue8 = new Queue<double>();
        public Queue<double> firstQueue9 = new Queue<double>();

THis works for me but what I would really like is an array.

Also is Queue threadsafe?

And why does  Queue<double>() not accept an initial capacity
argument like         Queue firstQueue0 = new Queue(100); does?

Thanks!

- mrmox

mrmoxAsked:
Who is Participating?
 
dj_alikConnect With a Mentor Commented:
1.   public Queue<double>[] queues = new  Queue<double>[2];

2. Queue.Synchronized Method
http://msdn.microsoft.com/en-us/library/system.collections.queue.synchronized.aspx 
0
 
wdosanjosCommented:
The Queue constructor with a initial capacity parameter is only available on .NET Framework 4.  Prior versions of the framework does not have that option.
0
 
wdosanjosConnect With a Mentor Commented:
BTW, regarding @dj_alik solution, you also need to initialize it as follows:

public Queue<double>[] queues = new Queue<double>[10];

for (int i=0; i < queues.Length; i++) queues[i] = new Queue();  // in your constructor

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
anarki_jimbelCommented:
OK, I believe wdosanjos gives wrong information. See
 http://msdn.microsoft.com/en-us/library/system.collections.queue.queue(v=VS.80).aspx
for the 2.0Queue class:

"Queue (Int32)       Initializes a new instance of the Queue class that is empty, has the specified initial capacity, and uses the default growth factor."

About arrays. I believe the asker has VB experience and tried to create an array using "()" brackets instead of "[]". I do this mistake quite often when switching from VB to C#...

dj_alik answered about thread safety.

0
 
wdosanjosCommented:
@anarki_jimbel, you are right. Sorry, for the misinformation.
0
 
mrmoxAuthor Commented:
Thank you, I am now able to instantiate an array of queues.
Some of my confusion may have been in thinking
I should be able to instantiate the array and
populate it with queue objects in one step/line.
So, the part from @wdosanjos was useful to me.
I would still like to understand why Queue<double>
and Queue come from different places but I did not ask
that specifically I realize.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.