#region
// 1、去掉特殊符号,将字符串反转;
方法1:
string str = "AB,CD+E-F+G,HI-J,K-Nansen";
string[] strArr = str.Split(new char[] { ',', '+', '-' }, StringSplitOptions.RemoveEmptyEntries);
str = strArr.Aggregate((s1, s2) => s1 + s2);
char[] chArr = str.ToCharArray();
string joinStr = null;
Array.Reverse(chArr);
joinStr = new string(chArr);
Console.WriteLine(joinStr);
输出:nesnaNKJIHGFEDCBA
方法2:
string str = "AB,CD+E-F+G,HI-J,K-Nansen";
string[] strArr = str.Split(new char[] { ',', '+', '-' }, StringSplitOptions.RemoveEmptyEntries);
str = strArr.Aggregate((s1, s2) => s1 + s2);
char[] chArr = str.ToCharArray();
string joinStr = null;
Array.Reverse(chArr);
//用For将数组组成字符串;
for (int i = 0; i < chArr.Length; i++)
{
joinStr += chArr[i];
}
Console.WriteLine(joinStr);
输出:nesnaNKJIHGFEDCBA