C# Interview

Generics & Collections

C# interview questions covering generics & collections.

10 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

10 Results
31
Mid-LevelIntermediate

What are generics in C#?

Generics allow classes, interfaces, methods, delegates, and other types to operate with type parameters instead of being written for one specific data type.

32
Mid-LevelIntermediate

What are generic constraints in C#?

Generic constraints restrict which types can be supplied for a generic type parameter. They allow generic code to safely use capabilities guaranteed by the constraint.

33
Mid-LevelIntermediate

What is a collection in C#?

A collection is an object used to store and manage groups of values or objects. .NET provides generic collections in System.Collections.Generic for common data structures.

34
Mid-LevelIntermediate

What is the difference between an array and List<T>?

An array has a fixed length after creation, while List<T> is a dynamically sized generic collection.

35
Mid-LevelIntermediate

What is List<T> in C#?

List<T> is a generic, dynamically sized collection that stores elements of a specified type. It preserves insertion order and supports indexed access.

36
Mid-LevelIntermediate

What is Dictionary<TKey, TValue> in C#?

Dictionary<TKey,TValue> stores data as key-value pairs. Each key must be unique, and values are retrieved using their associated keys.

37
Mid-LevelIntermediate

What is IEnumerable<T> in C#?

IEnumerable<T> represents a sequence that can be enumerated one element at a time. It is the fundamental generic interface used by foreach and many LINQ operations.

38
Mid-LevelIntermediate

What is the difference between IEnumerable<T> and ICollection<T>?

IEnumerable<T> provides basic sequential enumeration. ICollection<T> extends IEnumerable<T> and represents a collection that exposes additional operations and information.

39
Mid-LevelIntermediate

What is the difference between IEnumerable<T> and IQueryable<T>?

IEnumerable<T> represents an enumerable sequence and its LINQ operations normally execute as .NET code over objects.

40
Mid-LevelIntermediate

What are Stack<T> and Queue<T> in C#?

Stack<T> and Queue<T> are generic collections designed for different processing orders.