当前位置: 代码迷 >> C# >> 如何把十六进制的字符串格式化对齐
  详细解决方案

如何把十六进制的字符串格式化对齐

热度:315   发布时间:2016-04-28 08:38:03.0
怎么把十六进制的字符串格式化对齐?
682419700600006803203233333A333333333EF7D8808AB24355F4C9F8A9FD8C4796574CA33933333333B416
这样的16进制字符串怎么格式化对齐,需要这样的
68 24 19 70 06 00 00 68 03 20 32 33 33 3A 33 33 33 。。。。。。。
------解决思路----------------------
string txt = @"682419700600006803203233333A333333333EF7D8808AB24355F4C9F8A9FD8C4796574CA33933333333B416";
txt = string.Join(" ", Regex.Split(txt, @"(?<=^(?:\w{2})+)"));
Console.WriteLine(txt);

------解决思路----------------------
引用:
txt = string.Join(" ", Regex.Split(txt, @"(?<=^(?:\w{2})+)"));

@starfd,建议不要给出这样的代码。或者至少要备注它的短处。