将十六进制字符串转换为逗号分隔的十六进制字符串c# [英] Convert a Hex String to comma separated Hex String c#
本文介绍了将十六进制字符串转换为逗号分隔的十六进制字符串c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在文本框中输入一系列十六进制数字,并且当用户单击按钮时,用逗号分隔每个字节。 AAFFBCEE变为AA,FF,BC,EE(最后一个字节无逗号)。如何将字符串值转换为这种格式?
I want to input a series of Hex numbers into a textBox and when the user hits a button separate each byte with a comma. AAFFBCEE becomes AA,FF,BC,EE (no comma on last byte). how can I convert a string value to this format?
推荐答案
string temp = "aaff4455";
string temp2 = "";
int size = temp.Length;
for (int i = 0; i < size; i += 2)
{
temp2 += temp.Substring(i, 2);
if ((i+2) < size)
temp2 += ",";
}
这篇关于将十六进制字符串转换为逗号分隔的十六进制字符串c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文