3
Answers

C++ to C# (checksum)

Puneet Gupta

Puneet Gupta

11y
1.8k
1
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)