Sheraf
Sheraf
CC#
Created by Sheraf on 3/13/2023 in #help
❔ 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 });
_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);
}
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'
error CS0021: Cannot apply indexing with [] to an expression of type 'object'
64 replies