C# 12 - Collection Expression
Dotnet 8 과 함께 Collection Expression 이라는 유용한 기능이 추가 되었다. 아래 코드를 보자 int[] agesArray = { 10, 15, 20, 35, 45, 70, 100, 150 }; List agesList = new() { 10, 15, 20, 35, 45, 70, 100, 150 }; PrintAgesCount(agesArray); PrintAgesCount(agesList); PrintAgesCount(new List()); void PrintAgesCount(IEnumerable ages) { Console.WriteLine($"count of age is {ages.Count()} ages"); } 코드를 보면 int[] 와 List 를 초기화 하는 코드가 미..
2023.12.25