小编use*_*215的帖子

对于无符号字节来说,值太大或太小

出现以下错误:

已引发 System.OverflowException - 对于无符号字节,值太大或太小。

有谁知道如何解决它?

class MainClass
{
    public static void Main(string[] args)
    {
            int decValue = 2210;
            string bin = Convert.ToString(decValue, 2);
            string lowerbyte = bin.Substring(Math.Max(0, bin.Length - 16));

            if (lowerbyte.Length < 16)
            {
                lowerbyte = lowerbyte.PadLeft(16, '0');
            }


        Int16 circular = Convert.ToByte(CicrularLeftShift(lowerbyte, 3), 2);

            string xored = Convert.ToString((circular ^ 38556), 2).Substring(Math.Max(0, Convert.ToString((circular ^ 38556), 2).Length - 16));

            //converting final binary shift value to HEX
            string finalHex = Convert.ToString(Convert.ToInt32(xored, 2), 16).ToUpper();

        Console.WriteLine(finalHex);

    }

    private static string CicrularLeftShift(string key, …
Run Code Online (Sandbox Code Playgroud)

c#

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1