110,536
社区成员
发帖
与我相关
我的任务
分享
string str = "123456";
string s = BitConverter.ToString(BitConverter.GetBytes(Convert.ToInt32(str)));
int len = s.Split('-').Length;
s = s.Replace("-", " ");
while (len < 6)//把6改为你要补全的位数
{
s += " 00";
len++;
}
Console.WriteLine(s);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string s = "123456";
long num = long.Parse(s);
byte[] arr = BitConverter.GetBytes(num);
Console.ReadKey();
}
}
}