如何以下列格式显示byte []内容 [英] how do I display a byte [] content in the following format

查看:100
本文介绍了如何以下列格式显示byte []内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void btnResize_Click(object sender, EventArgs e)
     {
         Width = 580;
         Height = 487;
       //  string []buffer =new byte[ richTextBox2.Text];

         byte[] buffer = Encoding.Default.GetBytes(richTextBox2.Text);

       //  byte[] buffer = BitConverter.GetBytes(Convert.ToDouble(richTextBox2.Text));

         // From byte array to string

         string bb = "";
         int i = 0;
         ////int numBytesToRead = buffer.Length;
         while (i < richTextBox2.TextLength)
         {
             if ((i % 8) == 0)
             {
                 bb = bb + "\n";
                 bb = bb + i.ToString("X8");
                 bb = bb + "\t";
             }
             else if ((i % 4) == 0)
             {
                 bb = bb + "\t";
             }
             bb = bb + buffer[i].ToString("X2"); // modified on 30june2014

             i = i + 1;
         }
         richTextBox2.Text = bb;

     }



其实我在richtexbox2中以下列格式显示十六进制数据

00000000 4D696372 6F736F66 74205351 4C205365

00000010 72766572 20416E61 6C797369 73205365



现在当我点击表格中的调整大小按钮时,上面的数据应该是如下格式

00000000 4D696372 6F736F66

00000008 74205351 4C205365

00000010 72766572 20416E61

00000018 6C797369 73205365


Actually I did the display of hex data in richtexbox2 in following format
00000000 4D696372 6F736F66 74205351 4C205365
00000010 72766572 20416E61 6C797369 73205365

now when I click to the resize button which is on the form the above data should be like following format
00000000 4D696372 6F736F66
00000008 74205351 4C205365
00000010 72766572 20416E61
00000018 6C797369 73205365

推荐答案

这篇关于如何以下列格式显示byte []内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆