public static void Main()
var safd = getSum("$GNRMC,130500.00,A,5919.50601,N,01805.07715,E,12.359,86.70,170122,6.75,E,D*");
var safd2 = getSum("GNRMC,130501.00,A,5919.50631,N,01805.08392,E,12.349,83.78,170122,6.75,E,D*");
Console.WriteLine(safd2);
public static string getSum(String str)
if (str.StartsWith("$")) {
str = str.Substring(1, str.Length - 1);
int end = str.IndexOf('*');
for (int i = 0; i < end; i++) {
checksum = checksum ^ str[i];
string hex = checksum.ToString("X");