Govt. Exams
Entrance Exams
Stack<T> follows LIFO (Last-In-First-Out) principle, making it ideal for undo/redo functionality where the most recent action is reversed first.
TryDequeue() returns false if the queue is empty and sets the out parameter to the default value of T, avoiding exceptions.
ElementAt() is a LINQ method that retrieves an element at a specific index. SortedSet<T> doesn't support direct indexing.
List<T> is a generic collection that avoids boxing of value types, whereas ArrayList boxes all values, causing performance overhead.
Modifying a Dictionary<K,V> while enumerating throws InvalidOperationException. This is a safety feature to prevent undefined behavior.
ConcurrentBag<T> from System.Collections.Concurrent provides thread-safe operations without explicit locking, suitable for multi-threaded scenarios.
SortedList uses less memory than SortedDictionary but has slower insertion/deletion. SortedDictionary is better for frequent modifications.
IndexOf() performs a linear search through the list, resulting in O(n) time complexity in the worst case.
OrderedDictionary maintains insertion order for key-value pairs. Dictionary<K,V> does not guarantee order in older versions; SortedDictionary sorts by key.
LinkedList<T> allows O(1) removal from both ends and maintains insertion order. Deque<T> is not a standard C# collection.