CRC byte assembly and disassembly

Hi,

I have a stream of bytes with a final crc byte I would like to compare with to check for errors.

in visual basic, it is written like this:

crc=0
For i=o To (n_rx - 2)
  crc += rxbuf(i)
Next i
crc = crc And HFF
If crc = rxbuf(n_rx -1)Then

How would I translate this to arduinian?

You've no supplied the VB code to declare the variables used so I'm assuming you can do this.

crc = 0;
for (i = o; i < n_rx - 2; i++)
{
  crc += rxbuf[i];
}

crc = crc & 0xff;
if (crc == rxbuf[n_rx - 1])
{
}

Thanks a lot