tags:

views:

63

answers:

1

How do I transform the following code in C#. My C is a little bit rusty (well... very very rusted):

short CalcCrc(char *str,int len)
{
  short crc=0;
  for(int i=0;i<len;i++)
    crc ^= (short)((unsigned char)str[i]) << (i%9);
  return crc;
}

Thank you!

+2  A: 
    short CalcCrc(string str)
    {
        short crc = 0;
        for (int i = 0; i < str.Length; i++)
            crc ^= (short)(str[i] << (i % 9));
        return crc;
    }
Kikaimaru