110,536
社区成员
发帖
与我相关
我的任务
分享
byte[] inputBytes;
string inputString = System.Convert.ToBase64String(inputBytes);
static void Main(string[] args)
{
string stra = "2e4abd10";
byte[] result = ParseByteArray(stra);
PrintByteArray(result);
}
static byte[] ParseByteArray(string str)
{
int arrayLength = str.Length / 2;
byte[] byteArray = new byte[arrayLength];
for (int i = 0; i < arrayLength; ++i)
{
byteArray[i] = byte.Parse(str.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
}
return byteArray;
}
static void PrintByteArray(byte[] byteArray)
{
Console.Write("{");
foreach (byte item in byteArray)
{
Console.Write(" 0x" + item.ToString("x02"));
}
Console.WriteLine(" }");
}
static void Main(string[] args)
{
string stra = "2e4abd10";
byte[] result = ParseByteArray(stra);
}
static byte[] ParseByteArray(string str)
{
int arrayLength = str.Length / 2;
byte[] byteArray = new byte[arrayLength];
for (int i = 0; i < arrayLength; ++i)
{
byteArray[i] = byte.Parse(str.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
}
return byteArray;
}