const int INIT_VALUE = 0;
private long[] CRC16Table = new long[257];
public void Crc16Checksum()
public void SetValue(int v)
for (i = 0; i <= 255; i++)
if (((crc ^ K) & 0x8000L) != 0)
crc = ((crc * 2) & 65535) ^ 0x1021L;
public long Update(int v)
lngValue1 = ((lngValue & 0xff00L) / 256) & 0xffL;
lngValue1 = CRC16Table[lngValue1];
lngValue2 = ((lngValue & 0xffL) * 256L) & 0xff00L;
lngValue = lngValue1 ^ lngValue2 ^ lngValue3;
public long UpdateString(string message)
for (i = 0; i < intLen; i++)
Console.WriteLine((Int)System.Convert.ToChar(message.Substring(i, 1)));
lngRet = Update((int)System.Convert.ToChar(message.Substring(i, 1)));
Console.WriteLine(lngRet);
public static void Main()
Program xyz = new Program();
long lng = xyz.Update(272727);
xyz.UpdateString("String");
Console.WriteLine(str.Substring(0,1));