从septets转换为octet [英] conversion from septets to octets

查看:86
本文介绍了从septets转换为octet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码,可以将十六进制转换为七段式
字符串hexvalue = textBox1.Text;
字符串binaryval = textBox2.Text;
binaryval = Convert.ToString(Convert.ToInt32(hexvalue,16),2);

textBox2.Text = binaryval;

但是现在我想将这些septet转换为八位字节,有人可以帮助我吗?

i have this code for the conversion of hex into septets
string hexvalue = textBox1.Text;
string binaryval = textBox2.Text;
binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 2);

textBox2.Text = binaryval;

but now i want to convert these septets into octets, can anyone help me?

推荐答案

 private void septetToOctet()
{
    int len = 1;
    int j = 0;
    int septetcount = septet.Count;

    while (j < septet.Count - 1)
    {

        string tmp = septet[j]; // storing jth value
        string tmp1 = septet[j + 1]; //storing j+1 th value
        string mid = SWAP(tmp1);
        tmp1 = mid;
        tmp1 = tmp1.Substring(0, len);
        string add = SWAP(tmp1);
        tmp = add + tmp;// +"-";
        tmp = tmp.Substring(0, 8);
        //txtoctet.Text += tmp + " || ";
        octet.Add(tmp);
        len++;
        if (len == 8)
        {
            len = 1;
            j = j + 1;
        }
        j = j + 1;

      }

  }


这篇关于从septets转换为octet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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