Linq Example 35 - Sum Projection

2:25 AM
Linq Query:

//Sum Projection
            string[] s = { "abc", "abcd", "ab", "a" };

            int totalChars = s.Sum(n => n.Length);

            Console.WriteLine(totalChars);

//

Output:

10

0 comments:

Post a Comment