本文介绍了在C#中阅读Bynary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我创建了一个文本文件,编码为 ASCII 。它包含以下文字; I''ve created a text file Encoded in ASCII. It Contains the Following Text;abcd123 以上文字的二进制值; Binary value of the above text ;01100001 01100010 01100011 01100100 0110001 0110010 0110011 如何在C#中执行此操作(将文件的二进制值转换为文本框)?How Can I do this (getting binary value of a file to a text box) in C# ?推荐答案 byte[] data = File.ReadAllBytes(path); 转换为二进制很简单:MSDN [ ^ ] Converting to binary is easy: MSDN[^]string s = Convert.ToString(myByte, 2); 将它们与foreach循环和StringBuilder放在一起,你就有了一个程序... 但是,既然这是你的功课,我就把实际的代码留给你了! :笑:Put them together with a foreach loop and a StringBuilder and you have a program...But, since this is your homework, I''m leaving the actual code to you! :laugh: var str = "abcd123"; foreach (string letter in str.Select(c => Convert.ToString(c, 2))) { Console.WriteLine(letter); } Console.ReadLine(); 更多参考: - 如何在C#中将字符串转换为ascii为二进制文件 [ ^ ] 这篇关于在C#中阅读Bynary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 07:56