C# Programming - MCQ Practice Questions
C# (.NET) MCQs — OOP, collections, LINQ & exception handling.
290 questions | 100% Free
Which method removes all elements from a collection in C#?
What is the time complexity of accessing an element by index in a List<T>?
Which collection maintains insertion order but uses a hash table for faster lookups?
What happens when you try to access an index beyond the Count in a List<T>?
Which interface must be implemented to use a collection in a foreach loop?
What is the difference between Stack<T>.Push() and Stack<T>.Pop()?
Consider: Dictionary<string, int> dict = new(); dict.Add("a", 1); dict.Add("a", 2); What happens?
Which collection should be used when you need sorted key-value pairs automatically?
Which collection type is best suited for implementing a priority queue in C#?
What happens when you add a duplicate key to a Dictionary<TKey, TValue>?
Which LINQ method returns the first element matching a condition, or throws if none exists?
What is the primary difference between SortedList<TKey, TValue> and SortedDictionary<TKey, TValue>?
Which collection in C# is NOT thread-safe by default?
What does the Contains() method use in HashSet<T> to determine membership?
Which of the following collections preserves insertion order and is thread-safe?
What is the time complexity for removing an element from the middle of a LinkedList<T>?
In C# 2024-25, which collection should be used for fast membership testing with no duplicates?
What is the output of the following code? var dict = new Dictionary<int, string>(); dict[1] = "A"; dict[1] = "B"; Console.WriteLine(dict[1]);
Which collection in C# maintains insertion order and allows fast removal from both ends?
Which collection type should be used when you need key-value pairs with guaranteed order of insertion?