15,902,886 members
See more:
i have a byte array of 1024 size that contains decimal values. i want to add all values stored in the array. and want to calculate check sum.
Posted
BillWoodruff 8-Nov-13 10:25am
Your question is confusing: bytes represent integer values, not decimal. And it's very doubtful you'd have a byte array size #1024 which contained representations of .NET's decimal number Type.

Matt T Heffron 8-Nov-13 13:00pm
I'd GUESS that OP might have ASCII digits in each byte...
bunty swapnil 9-Nov-13 0:48am
i have a byte array of 1024 size.

byte[] datablock_appenddataIntoByte = StringToByteArray(datablock_appenddata);

and datablock_appenddata contains string of hex numbers.

and hexnumbers like:-B80C001061020000690200006B020000

i want to calculate check sum through crc-32.

## Solution 1

That's really a simple task: just iterate on all values adding each of it to a global sum variable. Computing che checksum is simple as well, once you know the checksum algorithm you have to use (see, for instance "Checksum" page at Wikipedia[^]).

bunty swapnil 8-Nov-13 6:16am
can u write code for addition.

byte[] datablock_appenddataIntoByte = StringToByteArray(datablock_appenddata);

this byte array contains 1024 bytes from 0-1023. i want to add all.
CPallini 8-Nov-13 6:24am
What's the problem?
int sum=0; foreach( byte b in array) sum += b;
bunty swapnil 8-Nov-13 6:51am
cpallini
can you help me to calculate check sum for this byte array.
Andreas Gieriet 8-Nov-13 7:28am
Is this a homework assignment and you are too lazy to read the text book? Skipped any earlier exercises of your training program?
Andi