Aggregate

对序列应用累加器函数。

 

        /// <summary>
        /// 计算校验和,SUM
        /// </summary>
        public byte CalculateCheckSum(byte[] data)
        {
            int sum = data.Aggregate(0, (current, t) => current + t);
            return (byte)(sum & 0x00ff);
        }

 

posted @ 2016-11-16 16:24  pkyou  阅读(281)  评论(1编辑  收藏  举报