© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
63 replies
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 });
_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'
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,828Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

✅ I dont understand this error in my code
C#CC# / help
2y ago
Hello! i am new to c # what editor should i use?
C#CC# / help
3y ago
I dont understand how this works
C#CC# / help
3y ago
I am new to C# (for unity)
C#CC# / help
3y ago