iGET

C# Programming - MCQ Practice Questions

C# (.NET) MCQs — OOP, collections, LINQ & exception handling.

290 questions | 100% Free

Q.1Medium

Which method removes all elements from a collection in C#?

Q.2Medium

What is the time complexity of accessing an element by index in a List<T>?

Q.3Medium

Which collection maintains insertion order but uses a hash table for faster lookups?

Q.4Medium

What happens when you try to access an index beyond the Count in a List<T>?

Q.5Medium

Which interface must be implemented to use a collection in a foreach loop?

Q.6Medium

What is the difference between Stack<T>.Push() and Stack<T>.Pop()?

Q.7Medium

Consider: Dictionary<string, int> dict = new(); dict.Add("a", 1); dict.Add("a", 2); What happens?

Q.8Medium

Which collection should be used when you need sorted key-value pairs automatically?

Q.9Medium

Which collection type is best suited for implementing a priority queue in C#?

Q.10Medium

What happens when you add a duplicate key to a Dictionary<TKey, TValue>?

Q.11Medium

Which LINQ method returns the first element matching a condition, or throws if none exists?

Q.12Medium

What is the primary difference between SortedList<TKey, TValue> and SortedDictionary<TKey, TValue>?

Q.13Medium

Which collection in C# is NOT thread-safe by default?

Q.14Medium

What does the Contains() method use in HashSet<T> to determine membership?

Q.15Medium

Which of the following collections preserves insertion order and is thread-safe?

Q.16Medium

What is the time complexity for removing an element from the middle of a LinkedList<T>?

Q.17Medium

In C# 2024-25, which collection should be used for fast membership testing with no duplicates?

Q.18Medium

What is the output of the following code? var dict = new Dictionary<int, string>(); dict[1] = "A"; dict[1] = "B"; Console.WriteLine(dict[1]);

Q.19Medium

Which collection in C# maintains insertion order and allows fast removal from both ends?

Q.20Medium

Which collection type should be used when you need key-value pairs with guaranteed order of insertion?