string input = "114,86,92,93,94,90,93,0,101,66,89,90,87,124,89"; string[] parts = input.Split(','); byte[] ip = new byte[parts.Length];

for (int i = 0; i < parts.Length; i++) { ip[i] = Convert.ToByte(parts[i]); }

string output = "var ip = new byte[] { "; for (int i = 0; i < ip.Length - 1; i++) { output += $"0x{ip[i]:X2}, "; } output += $"0x{ip[ip.Length - 1]:X2}, "; output += "};";

Console.WriteLine(output); // Output: var ip = new byte[] { 0x72, 0x56, 0x5C, 0x5D, 0x5E, 0x5A, 0x5D, 0x00, 0x65, 0x42, 0x59, 0x5A, 0x57, 0x7C, 0x59, }

字符串11486929394909301016689908712489 帮我用C#用分割后转16进制在转成var ip = new byte 0x72 0x56 0x5C 0x5D 0x5E 0x5A 0x5D 0x00 0x65 0x42 0x59 0x5A 0x57 0x7C 0x59 ;

原文地址: https://www.cveoy.top/t/topic/iIbz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录