form1.cs

来自「校验值计算器Code」· CS 代码 · 共 38 行

CS
38
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace XORCheckSum
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string[] HexStr = textBox1.Text.Trim().Split(' ');
            byte[] Hexbyte=new byte[HexStr.Length];
            byte check = 0;
            check = (byte)(Convert.ToByte(HexStr[0], 16) ^ Convert.ToByte(HexStr[1], 16));
            for (int i = 2; i < HexStr.Length; i++)
            {
                check = (byte)(check ^ Convert.ToByte(HexStr[i], 16));
            }
            string CheckSumHex = Convert.ToString(check,16);
            if (CheckSumHex.Length == 1)
            {
                CheckSumHex = "0" + CheckSumHex;
            }
            textBox2.Text = CheckSumHex.ToUpper();
            textBox3.Text = textBox1.Text.Trim() + " " + textBox2.Text;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?