C Sharp (C#) - LINQ Fundamentals
Identify the error in this code snippet:
var nums = new List<int> { 4, 2, 7 };
var sorted = nums.OrderBy(n => n);
sorted.Sort();var nums = new List<int> { 4, 2, 7 };
var sorted = nums.OrderBy(n => n);
sorted.Sort();OrderBy returns an IEnumerable<T>, not a List<T>.IEnumerable does not have a Sort method, so calling sorted.Sort() causes an error.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions