Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Use the Clear() method to remove all key-value pairs. Explain a bit more dictionary.Clear(); This resets the dictionary to an empty state. 📘 C# Queue<T> – Interview Questions &amp; Use the Clear(…
Short answer: Contains(item) checks whether the item exists in the list. It uses Equals() internally. Example code bool exists = list.Contains(10); Note: For custom objects, override Equals() and GetHashCode(). Real-worl…
Short answer: Capacity is the number of elements the list can hold before resizing. It is greater than or equal to Count. Example code list.Capacity = 100; // Optional performance tuning Real-world example (ShopNest) In…
Short answer: Property Meaning Count Number of elements currently in the list Capacit Total allocated slots (memory reserved) Example code Console.WriteLine($"Count: {list.Count}, Capacity: {list.Capacity}"); R…
Short answer: Use GroupBy, Distinct, or nested loops. Example: bool hasDuplicates = list.Count != list.Distinct().Count(); Example code Use GroupBy, Distinct, or nested loops. Example: bool hasDuplicates = list.Count !=…
Short answer: Use ToArray() method. Example: int[] array = list.ToArray(); Useful when interfacing with APIs that require arrays. Example code Use ToArray() method. Example: int[] array = list.ToArray(); Useful when inte…
Short answer: list = list.Distinct().ToList(); For custom objects, override Equals() and GetHashCode(). Example code list = list.Distinct().ToList(); For custom objects, override Equals() and GetHashCode(). Real-world ex…
Short answer: Use IndexOf(item) or FindIndex(predicate). Example: int index = list.IndexOf(10); int indexByCondition = list.FindIndex(x => x > 100); 📘 C# Dictionary<TKey, TValue> – Interview Questions &…
C# Collections C# Programming Tutorial · Collections
Short answer: Use the Clear() method to remove all key-value pairs.
dictionary.Clear(); This resets the dictionary to an empty state. 📘 C# Queue<T> – Interview Questions & Use the Clear() method to remove all key-value pairs. dictionary.Clear(); This resets the dictionary to an empty state. 📘 C# Queue<T> – Interview Questions & Use the Clear() method to remove all key-value pairs. dictionary.Clear(); This resets the dictionary to an empty state. 📘 C# Queue<T> – Interview Questions & Use the Clear() method to remove all key-value pairs. dictionary.Clear(); This resets the dictionary to an empty state. 📘 C# Queue<T> – Interview Questions &
ShopNest caches product prices in a Dictionary<string, decimal> keyed by SKU so checkout can look up a price in O(1) instead of scanning a list.
C# Collections C# Programming Tutorial · Collections
Short answer: Contains(item) checks whether the item exists in the list. It uses Equals() internally.
bool exists = list.Contains(10); Note: For custom objects, override Equals() and GetHashCode().
In ShopNest, an order page loads products with List<Product> so you can Add items to the cart and access them by index. Use IEnumerable<T> when you only need to loop (for example, printing invoice lines).
C# Collections C# Programming Tutorial · Collections
Short answer: Capacity is the number of elements the list can hold before resizing. It is greater than or equal to Count.
list.Capacity = 100; // Optional performance tuning
In ShopNest, an order page loads products with List<Product> so you can Add items to the cart and access them by index. Use IEnumerable<T> when you only need to loop (for example, printing invoice lines).
C# Collections C# Programming Tutorial · Collections
Short answer: Property Meaning Count Number of elements currently in the list Capacit Total allocated slots (memory reserved)
Console.WriteLine($"Count: {list.Count}, Capacity: {list.Capacity}");
In ShopNest, an order page loads products with List<Product> so you can Add items to the cart and access them by index. Use IEnumerable<T> when you only need to loop (for example, printing invoice lines).
C# Collections C# Programming Tutorial · Collections
Short answer: Use GroupBy, Distinct, or nested loops. Example: bool hasDuplicates = list.Count != list.Distinct().Count();
Use GroupBy, Distinct, or nested loops. Example: bool hasDuplicates = list.Count != list.Distinct().Count();
In ShopNest, an order page loads products with List<Product> so you can Add items to the cart and access them by index. Use IEnumerable<T> when you only need to loop (for example, printing invoice lines).
C# Collections C# Programming Tutorial · Collections
Short answer: Use ToArray() method. Example: int[] array = list.ToArray(); Useful when interfacing with APIs that require arrays.
Use ToArray() method. Example: int[] array = list.ToArray(); Useful when interfacing with APIs that require arrays.
In ShopNest, an order page loads products with List<Product> so you can Add items to the cart and access them by index. Use IEnumerable<T> when you only need to loop (for example, printing invoice lines).
C# Collections C# Programming Tutorial · Collections
Short answer: list = list.Distinct().ToList(); For custom objects, override Equals() and GetHashCode().
list = list.Distinct().ToList();
For custom objects, override Equals() and GetHashCode().
In ShopNest, an order page loads products with List<Product> so you can Add items to the cart and access them by index. Use IEnumerable<T> when you only need to loop (for example, printing invoice lines).
C# Collections C# Programming Tutorial · Collections
Short answer: Use IndexOf(item) or FindIndex(predicate). Example: int index = list.IndexOf(10); int indexByCondition = list.FindIndex(x => x > 100); 📘 C# Dictionary<TKey, TValue> – Interview Questions & Answers
Use IndexOf(item) or FindIndex(predicate). Example: int index = list.IndexOf(10);
int indexByCondition = list.FindIndex(x => x > 100); 📘 C# Dictionary<TKey, TValue> – Interview Questions & Answers
In ShopNest, an order page loads products with List<Product> so you can Add items to the cart and access them by index. Use IEnumerable<T> when you only need to loop (for example, printing invoice lines).
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.