Puneet Gupta

Puneet Gupta

  • 932
  • 546
  • 53.8k

C++ to C# (checksum)

Oct 11 2013 6:44 AM
Can anyone convert this C++ code to C#

#include <stdio.h>
unsigned char calc_checksum(const char *s)
{
unsigned char result;
result = 0;
s++; // Skip dollar sign
while ((*s != '*') && (*s != '\0'))
result ^= *s++;
return result;
}
int main()
{
unsigned char checksum;
checksum = calc_checksum
("$GPRMC,235947.000,V,0000.0000,N,00000.0000,E,,,041299,,*");
printf("Checksum = %02X\n", checksum);
return 0;
}

I want same output in C# as i am getting in this c++ code. Please reply soon, Its very urgent.

Answers (3)