Query expression to get sum of string lengths.

Amatya
Posted by Amatya under C# category on | Points: 40 | Views : 1062
Query expression to get sum of string lengths using LINQ

var dnfList = new List<string> { "10", "200", "3000", "40000" };
int dnfLengthSum = (from x in dnfList select x.Length).Sum();



Result
dnfLengthSum : 14

Thanks
Amatya

Comments or Responses

Login to post response