using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FCS
{
public class FCSstr
{
public FCSstr()
{
}
public string tobcc(string s) //帧校验函数FCS
{
//获取s对应的字节数组
byte[] b = Encoding.ASCII.GetBytes(s);
// xorResult 存放校验结果。注意:初值去首元素值!
byte xorResult = b[0];
// 求xor校验和。注意:XOR运算从第二元素开始
for (int i = 1; i < b.Length; i++)
{
//**进行异或运算,^=就是异或运算符,具体可查阅异或运算
//**异或运算:两个二进制数的每一位进行比较,如果相同则为0,不同则为1,如下面2个10进制数37、 48的二进制值异或结果为21
//** 37(10) 100101(2)
//** 48(10) 110000(2)
//** 21(10) 010101(2)
//**这里的意思是:如a^=b,就是a与b先进行异或比较,得出的结果赋值给a;
xorResult ^= b[i];
}
//**Convert.ToSt