C#C
C#3y ago
Sheraf

❔ Hello I am new to C#, I dont understand this error:

I have a insert method that adds to queue:
_insertQueue.Enqueue(new object[] { database, collection, document });

and then in a thread loop:
while(_insertQueue.Count > 0)
                {
                    var items = _insertQueue.Dequeue();
                    var database = items[0];
                    var collection = items[1];
                    var document = items[2];
                    var db = _mongoClient.GetDatabase(database);
                    var col = db.GetCollection<BsonDocument>(collection);
                    col.InsertOne(document);
                }


but I'm getting this error:
error CS0021: Cannot apply indexing with [] to an expression of type 'object'
Was this page helpful?