iGET

C# Programming - MCQ Practice Questions

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

290 questions | 100% Free

Q.221Easy

What is the main difference between ArrayList and List<T> in C#?

Q.222Easy

Which collection allows duplicate keys in C#?

Q.223Easy

What does the Count property of a collection return in C#?

Q.224Easy

Which collection in C# implements LIFO (Last In First Out) principle?

Q.225Easy

What will be the output of the following code? List<int> nums = new List<int> {1, 2, 3}; nums.Add(4); Console.WriteLine(nums.Count);

Q.226Medium

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

Q.227Medium

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

Q.228Medium

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

Q.229Medium

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

Q.230Medium

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

Q.231Medium

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

Q.232Medium

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

Q.233Medium

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

Q.234Hard

In C# 2024-25, which LINQ method would you use to find all elements matching a condition in a List<T>?

Q.235Hard

What is the space complexity of a HashSet<T> with n elements storing unique values?

Q.236Hard

Consider: var result = list.OrderByDescending(x => x.Age).ThenBy(x => x.Name); What does this do?

Q.237Hard

What is the difference between ICollection<T> and IEnumerable<T> in terms of capabilities?

Q.238Hard

In a concurrent environment, which collection should be used instead of Dictionary<K,V> in C# 2024-25?

Q.239Easy

Which collection in C# maintains insertion order and allows duplicate elements?

Q.240Easy

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