Home > Back-end >  Written in c # to function class for help
Written in c # to function class for help

Time:05-06

For c # class will function as


Public int CRC16 (byte [] InputData, int nlen, ref byte [] ResCRC16)
{
Ushort Reg, temp, Crccode, I, j;
Reg=0 XFFFF;
Crccode=0 xa001;
for (i=0; I & lt; Nlen; I++)
{
Reg ^=InputData [I];
For (j=0; J & lt; 8; J++)
{
Temp=(ushort) (Reg & amp; 0 x0001);
Reg=(ushort) (Reg & gt;> 1);
If (temp==0 x0001)
Reg ^=Crccode;
}
}
ResCRC16 [1]=(byte) (Reg & amp; 0xff);
ResCRC16 [0]=(byte) ((Reg & gt;> 8) & amp; 0xff);
return 1;
}
  • Related