Func<byte[], long> f = (input) =>
{
long accumulator=0;
byte counter = 0;
for (counter=0; counter<input.Length -1; counter++)
accumulator += (input[counter] & 0xff) << (8 * counter);
return accumulator;
}
long result = f(new byte[] {0,4,1});
Or:
data.Select((value, index) => new KeyValuePair<int, byte>(index, value)).Sum(k => (k.Value & 0xff) << (8 * k.Key));