字节数组的按位OR

时间:2016-07-05 07:20:50

标签: c# linq

给定var a = new byte[] { 15, 4, 7, 81, ..., 4}。只需要快速获取a[0] | a[1] | ... | a[a.Length]

1 个答案:

答案 0 :(得分:4)

尝试

var a = new byte[] {15, 4, 7, 81, 4};
var result = a.Aggregate(0, (current, bt) => current | bt);