[不是问题]将二进制转换为八进制 [英] [Not a question] convert binary to octal
本文介绍了[不是问题]将二进制转换为八进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要帮助才能将二进制转换为八进制(int)
i非常感谢帮助或一些例子提前感谢。
Hi, I need help to convert binary to octal ( int )
i appreciate the help or some example thanks in advance.
推荐答案
任何数据都是一个字节块;在.NET中通常表示为数组 byte []
。每个字节可以表示为八进制字符串:
Any piece of data is a block of bytes; in .NET usually represented as the array byte[]
. And each byte can be represented as octal string:
byte[] data = //... read the file or whatever you have
//...
string octalNumber = System.Convert(data[someIndex], 8);
除此之外,转换您的数据你喜欢的方式。
string binary = "10011";
int integer = Convert.ToInt32(binary, 2);
string octal = Convert.ToString(integer, 8);
参考 - http://stackoverflow.com/questions/3781764/how-can-we-convert-binary-number-into-its-octal-number-using-c [ ^ ]
这篇关于[不是问题]将二进制转换为八进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文