iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.121Medium

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

Q.122Medium

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

Q.123Medium

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

Q.124Medium

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

Q.125Medium

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

Q.126Medium

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

Q.127Medium

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

Q.128Medium

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

Q.129Medium

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

Q.130Medium

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

Q.131Medium

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

Q.132Medium

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

Q.133Medium

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

Q.134Medium

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.135Medium

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

Q.136Medium

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

Q.137Medium

What is the time complexity of the IndexOf() method in List<T>?

Q.138Medium

What is the primary advantage of using SortedList<K,V> over SortedDictionary<K,V>?

Q.139Medium

In C# 2024-25, which collection should be used for thread-safe operations without explicit locking?

Q.140Medium

What happens when you enumerate a Dictionary<K,V> during modification?