iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.21Easy

Which collection throws an exception when you try to dequeue from an empty Queue<T>?

Q.22Easy

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

Q.23Medium

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

Q.24Medium

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

Q.25Medium

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

Q.26Medium

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

Q.27Medium

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

Q.28Medium

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

Q.29Medium

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

Q.30Medium

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

Q.31Easy

Which method in Stack<T> returns the top element without removing it?

Q.32Medium

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

Q.33Medium

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.34Hard

Which collection type allows you to iterate in reverse order efficiently?

Q.35Hard

What happens when you call Clear() on a Dictionary<TKey, TValue>?

Q.36Hard

Which LINQ method should you use to get distinct elements from a List<int> while maintaining performance?

Q.37Hard

In a competitive exam scenario, if you need both fast lookup and sorted iteration, which should you choose?

Q.38Medium

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

Q.39Easy

Which IEnumerable method should be used to filter elements based on a condition and maintain type safety?

Q.40Easy

In a HashSet<T>, what happens when you try to add a duplicate element?