我有以下代码:
//In a Class:
private BlockingCollection<T>[] _collectionOfQueues;
// In the Constructor:
_collectionOfQueues = new BlockingCollection<T>(new ConcurrentQueue<T>())[4];
我得到以下错误的底线:
无法使用 [] 将索引应用于“System.Collection.Concurrent.BlockingCollection”类型的表达式
即使我这样做:
_collectionOfQueues = new BlockingCollection<T>(new ConcurrentQueue<T>())[];
最后一个方括号出现错误:
语法错误;期望值
我正在尝试BlockingCollection
使用的集合制作一个数组,ConcurrentQueue
以便我可以做到:
_collectionOfQueues[1].Add(...);
// Add an item to the second queue
我做错了什么,我能做些什么来解决它?我可以不创建一个数组,BlockingCollection
我必须列出它吗?