<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#)

        How to convert a gi-normous integer (in string format) to hex format? (C#)(如何将 gi-normous 整数(字符串格式)转换为十六进制格式?(C#))

          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#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
                  Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
                  How to store delegates in a List(如何将代表存储在列表中)
                  How delegates work (in the background)?(代表如何工作(在后台)?)
                  C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
                  Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)
                • <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>
                    <tbody id='Slfis'></tbody>

                      <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'>