日期:2014-05-18 浏览次数:20763 次
var dictionary = "56789".ToDictionary(c => c, c => c - (char)'0'); decimal sum = "164238752901402".Sum(c => { int v; int i = dictionary.TryGetValue(c, out v) ? v : 0; return i; });
------解决方案--------------------
string str = "164238752901402";
int result = str.Select(x => x - '0').Where(x => x > 4).Sum();