zoukankan      html  css  js  c++  java
  • C#字节数组与字符串转换

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace 垃圾1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                byte[] a = new byte[8] { 0x43,0x51,0x30,0x30,0x30,0x30,0x30,0x31 };
                textBox1.Text = System.Text.ASCIIEncoding.UTF8.GetString(a);
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                string str = "CQ000001";
                byte[] b = new byte[8];
                b = System.Text.ASCIIEncoding.UTF8.GetBytes(str);
                for (int i = 0; i < 8; i++)
                {
                    textBox2.Text += b[i].ToString("x02");
                }
            }
    
    
        }
    }
  • 相关阅读:
    ACM TJU 1556
    HDU 1890 Robotie Sort
    Android学习笔记
    HDU 2795
    HDU 1542
    HDU 1698
    POJ 2185
    学习笔记
    HDU 3336
    HDU 3746
  • 原文地址:https://www.cnblogs.com/felixzh/p/4758086.html
Copyright © 2011-2022 走看看