<legend id='4L9Yk'><style id='4L9Yk'><dir id='4L9Yk'><q id='4L9Yk'></q></dir></style></legend>
<tfoot id='4L9Yk'></tfoot>
      <bdo id='4L9Yk'></bdo><ul id='4L9Yk'></ul>

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

        <small id='4L9Yk'></small><noframes id='4L9Yk'>

      2. 如何将 gi-normous 整数(字符串格式)转换为十六进制格式?(C#)

        时间:2023-05-20

          1. <legend id='YmpbQ'><style id='YmpbQ'><dir id='YmpbQ'><q id='YmpbQ'></q></dir></style></legend>
              <tfoot id='YmpbQ'></tfoot>

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

                • <bdo id='YmpbQ'></bdo><ul id='YmpbQ'></ul>

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

                • 本文介绍了如何将 gi-normous 整数(字符串格式)转换为十六进制格式?(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  给定一个潜在的巨大整数值(C# 字符串格式),我希望能够生成它的十六进制等效值.普通方法在这里不适用,因为我们谈论的是任意大的数字,50 位或更多.我见过的技术使用这样的技术:

                  Given a potentially huge integer value (in C# string format), I want to be able to generate its hex equivalent. Normal methods don't apply here as we are talking arbitrarily large numbers, 50 digits or more. The techniques I've seen which use a technique like this:

                  // Store integer 182
                  int decValue = 182;
                  // Convert integer 182 as a hex in a string variable
                  string hexValue = decValue.ToString("X");
                  // Convert the hex string back to the number
                  int decAgain = int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber);
                  

                  因为要转换的整数太大,所以不起作用.

                  won't work because the integer to convert is too large.

                  例如,我需要能够像这样转换字符串:

                  For example I need to be able to convert a string like this:

                  843370923007003347112437570992242323

                  843370923007003347112437570992242323

                  到它的十六进制等价物.

                  to its hex equivalent.

                  这些不起作用:

                  C# 将整数转换为十六进制并再次返回如何在 C# 中转换十六进制和十进制之间的数字?

                  推荐答案

                  哦,很简单:

                          var s = "843370923007003347112437570992242323";
                          var result = new List<byte>();
                          result.Add( 0 );
                          foreach ( char c in s )
                          {
                              int val = (int)( c - '0' );
                              for ( int i = 0 ; i < result.Count ; i++ )
                              {
                                  int digit = result[i] * 10 + val;
                                  result[i] = (byte)( digit & 0x0F );
                                  val = digit >> 4;
                              }
                              if ( val != 0 )
                                  result.Add( (byte)val );
                          }
                  
                          var hex = "";
                          foreach ( byte b in result )
                              hex = "0123456789ABCDEF"[ b ] + hex;
                  

                  这篇关于如何将 gi-normous 整数(字符串格式)转换为十六进制格式?(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:byte + byte = int ... 为什么? 下一篇:使用“as"有意义吗?即使没有空检查而不是强制转换?

                  相关文章

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

                    1. <legend id='Slfis'><style id='Slfis'><dir id='Slfis'><q id='Slfis'></q></dir></style></legend>

                      • <bdo id='Slfis'></bdo><ul id='Slfis'></ul>

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