private void button3_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); string str = "686B666B686B666B706B5D9BACAFA0AC5D683532303833393737"; for ( int i = 0; i < str.Length; i++) { if (i % 2 == 1) //奇数 ...1 { sb.Append(str[i]); sb.Append(" "); continue; } sb.Append(str[i]); } var result = sb.ToString(); }
//指定数据前移
strlist = new string[] { "","A","", "B" }; for (int i = 0; i < strlist.Length; i++) { //空数据 前移 if (strlist[i] == "") { test(strlist, i); } } public void test(string[] strlist, int index) { for (int i = index; i < strlist.Length; i++) { if (i + 1 >= strlist.Length) { strlist[i] = ""; //要替换的值 continue; } strlist[i] = strlist[i + 1]; } }
ssid
private void button3_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); string str = "686B666B686B666B706B5D9BACAFA0AC5D683532303833393737"; for (int i = 0; i < str.Length; i++) { if (i % 2 == 1) //奇数 ...1 { sb.Append(str[i]); sb.Append(" "); continue; } sb.Append(str[i]); } string result = sb.ToString(); string[] strlist = result.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);//返回值不包含空字符串元素, //去掉第三个和第7个 3=(i+1) i=2 第三个是2; 第七个是6; 取前8个字节 strlist[2] = ""; strlist[6] = ""; for (int i = 0; i < strlist.Length; i++) { //空数据 前移 if (strlist[i] == "") { test(strlist, i); } } List<string> list = new List<string>(); for (int i = 0; i < strlist.Length; i++) { list.Add(strlist[i]); if (i == (8 - 1)) { break; } } //--减去37+30 = 67; sb.Length = 0; for (int i = 0;i<list.Count;i++) { var t = Convert.ToInt32(list[i]) - 67; sb.Append(t); } } public void test(string[] strlist, int index) { for (int i = index; i < strlist.Length; i++) { if (i + 1 >= strlist.Length) { strlist[i] = ""; //要替换的值 continue; } strlist[i] = strlist[i + 1]; } }
private void button3_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); string str = "686B666B686B666B706B5D9BACAFA0AC5D683532303833393737"; for (int i = 0; i < str.Length; i++) { if (i % 2 == 1) //奇数 ...1 { sb.Append(str[i]); sb.Append("
"); continue; } sb.Append(str[i]); } string result = sb.ToString(); string[] strlist = result.Split("
".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);//返回值不包含空字符串元素,
//去掉第三个和第7个 3=(i+1) i=2 第三个是2; 第七个是6; 取前8个字节 strlist[2] = ""; strlist[6] = "";
for (int i = 0; i < strlist.Length; i++) { //空数据 前移 if (strlist[i] == "") { test(strlist, i); } }
List<string> list = new List<string>(); for (int i = 0; i < strlist.Length; i++) { list.Add(strlist[i]); if (i == (8 - 1)) { break; } } //--减去37+30 = 67; sb.Length = 0; for (int i = 0;i<list.Count;i++) {
var t = Convert.ToInt32(list[i]) - 67;
sb.Append(t);
}
}
public void test(string[] strlist, int index) { for (int i = index; i < strlist.Length; i++) { if (i + 1 >= strlist.Length) { strlist[i] = ""; //要替换的值 continue; } strlist[i] = strlist[i + 1]; } }