Could you explain on the following example what a deferred execution is and what materialization is? What will the output be?
string[] animals = { "dog", "cat", "crocodile", "Peter" };
var list = new List<string>(animals);
IEnumerable<string> query = list.Where(p => p.Length == 5);
list.Remove("Peter");
Console.WriteLine(query.Count());
Experience Level: Not defined
Tags: .NETC#LINQPerformance
Answer
Related C# job interview questions
Do you use generics? What are they good for? And what are constraints and why to use them?
.NETC#Performance Not definedCould you explain what the following LINQ methods OrderBy, Where and Single do and what will be the output of the code?
.NETC#LINQ Not definedWhat array initialization syntaxes do you know?
.NETC# Not definedHow does the .Max(...) work in LINQ? What will be the result of the following code?
.NETC#LINQ Not definedWhat is a difference between partial class and partial method and what are they good for?
.NETC# Not defined