C# Interview

Advanced LINQ, Expressions & Collections

C# interview questions covering advanced linq, expressions & collections.

10 Questions Filter by level

Interview questions

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

10 Results
121
SeniorAdvanced

What is an expression tree in C#?

An expression tree represents code as a tree-like data structure rather than immediately compiling it into executable instructions.

122
SeniorAdvanced

What is the difference between Func<T, bool> and Expression<Func<T, bool>>?

Func<T,bool> is a compiled delegate that can execute C# logic directly. Expression<Func<T,bool>> is a data structure representing the lambda expression.

123
SeniorAdvanced

What is the difference between ToList(), ToArray(), and AsEnumerable()?

ToList() immediately enumerates a sequence and stores the results in a List<T>. ToArray() also materializes immediately but stores the results in an array.

124
SeniorAdvanced

What is materialization in LINQ and Entity Framework Core?

Materialization is the process of executing a query and creating in-memory objects from its results.

125
SeniorAdvanced

What is a HashSet<T>, and when should it be used?

HashSet<T> is a generic collection that stores unique values and provides efficient membership checks.

126
SeniorAdvanced

What is the difference between Dictionary<TKey,TValue> and ConcurrentDictionary<TKey,TValue>?

Dictionary<TKey,TValue> is a general-purpose key-value collection and is not designed for unsynchronized concurrent writes.

127
SeniorAdvanced

What is an IComparer<T> in C#?

IComparer<T> defines custom ordering logic through the Compare method. It is useful when objects need to be sorted using a rule that is separate from the object's natural ordering.

128
SeniorAdvanced

What is IEqualityComparer<T> in C#?

IEqualityComparer<T> defines custom equality and hash-code logic for a type without changing the type itself.

129
SeniorAdvanced

What are immutable collections in .NET?

Immutable collections create a new collection when a change is requested rather than modifying the existing instance.

130
SeniorAdvanced

What is the difference between IEnumerable<T>, IReadOnlyCollection<T>, and IReadOnlyList<T>?

IEnumerable<T> guarantees only that a sequence can be enumerated.