<bdo id='rieMG'></bdo><ul id='rieMG'></ul>

    <small id='rieMG'></small><noframes id='rieMG'>

  • <legend id='rieMG'><style id='rieMG'><dir id='rieMG'><q id='rieMG'></q></dir></style></legend>
    <tfoot id='rieMG'></tfoot>

      1. <i id='rieMG'><tr id='rieMG'><dt id='rieMG'><q id='rieMG'><span id='rieMG'><b id='rieMG'><form id='rieMG'><ins id='rieMG'></ins><ul id='rieMG'></ul><sub id='rieMG'></sub></form><legend id='rieMG'></legend><bdo id='rieMG'><pre id='rieMG'><center id='rieMG'></center></pre></bdo></b><th id='rieMG'></th></span></q></dt></tr></i><div id='rieMG'><tfoot id='rieMG'></tfoot><dl id='rieMG'><fieldset id='rieMG'></fieldset></dl></div>
      2. 如何在 C# 中将字符串转换为 ascii 到二进制?

        时间:2023-06-03

          <small id='2f1QO'></small><noframes id='2f1QO'>

        • <i id='2f1QO'><tr id='2f1QO'><dt id='2f1QO'><q id='2f1QO'><span id='2f1QO'><b id='2f1QO'><form id='2f1QO'><ins id='2f1QO'></ins><ul id='2f1QO'></ul><sub id='2f1QO'></sub></form><legend id='2f1QO'></legend><bdo id='2f1QO'><pre id='2f1QO'><center id='2f1QO'></center></pre></bdo></b><th id='2f1QO'></th></span></q></dt></tr></i><div id='2f1QO'><tfoot id='2f1QO'></tfoot><dl id='2f1QO'><fieldset id='2f1QO'></fieldset></dl></div>
        • <tfoot id='2f1QO'></tfoot>
          • <bdo id='2f1QO'></bdo><ul id='2f1QO'></ul>
                <tbody id='2f1QO'></tbody>
            • <legend id='2f1QO'><style id='2f1QO'><dir id='2f1QO'><q id='2f1QO'></q></dir></style></legend>

                  本文介绍了如何在 C# 中将字符串转换为 ascii 到二进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  不久前(高中一年级),我请一位非常优秀的 C++ 程序员,他是一名大三学生,制作了一个将字符串转换为二进制的简单应用程序.他给了我以下代码示例:

                  A while back (freshman year of high school) I asked a really good C++ programmer who was a junior to make a simple application to convert a string to binary. He gave me the following code sample:

                  void ToBinary(char* str)
                  {
                      char* tempstr;
                      int k = 0;
                  
                      tempstr = new char[90];
                  
                      while (str[k] != '')
                      {
                          itoa((int)str[k], tempstr, 2);
                          cout << "
                  " << tempstr;
                          k++;
                      }
                  
                      delete[] tempstr;
                  }
                  

                  所以我想我的问题是如何在 C# 中获得与 itoa 函数等效的函数?或者如果没有,我怎么能达到同样的效果?

                  So I guess my question is how do I get an equivalent to the itoa function in C#? Or if there is not one how could I achieve the same effect?

                  推荐答案

                  这在 C# 中很容易做到.

                  This is very easy to do with C#.

                  var str = "Hello world";
                  
                  With LINQ
                  foreach (string letter in str.Select(c => Convert.ToString(c, 2)))
                  {
                    Console.WriteLine(letter);
                  }
                  
                  Pre-LINQ
                  foreach (char letter in str.ToCharArray())
                  {
                    Console.WriteLine(Convert.ToString(letter, 2));
                  }
                  

                  这篇关于如何在 C# 中将字符串转换为 ascii 到二进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将长二进制字符串转换为十六进制c# 下一篇:将 SQL Server varBinary 数据转换为字符串 C#

                  相关文章

                  最新文章

                  • <bdo id='77xnS'></bdo><ul id='77xnS'></ul>

                  1. <tfoot id='77xnS'></tfoot>

                    <small id='77xnS'></small><noframes id='77xnS'>

                    1. <i id='77xnS'><tr id='77xnS'><dt id='77xnS'><q id='77xnS'><span id='77xnS'><b id='77xnS'><form id='77xnS'><ins id='77xnS'></ins><ul id='77xnS'></ul><sub id='77xnS'></sub></form><legend id='77xnS'></legend><bdo id='77xnS'><pre id='77xnS'><center id='77xnS'></center></pre></bdo></b><th id='77xnS'></th></span></q></dt></tr></i><div id='77xnS'><tfoot id='77xnS'></tfoot><dl id='77xnS'><fieldset id='77xnS'></fieldset></dl></div>
                      <legend id='77xnS'><style id='77xnS'><dir id='77xnS'><q id='77xnS'></q></dir></style></legend>