INPUT DATA: pv1[7] 数组中的值比如说是test8^test8^test8^test8^
OUTPUT DATA: pv1[7]数组中的值是^test8^test8^test8^string[] pv1_7temp = pv1[7].Split('^');
pv1_7temp[0] = "";
string str_temp = "";foreach (string str in pv1_7temp)
{
str_temp += str + "^";
pv1[7] = str_temp;
}输出的结果总是在最后一位多出一个^ = ^test8^test8^test8^^.
请教各位有什么办法只将第一位字符remove,其它的值不变。
Thanks,
OUTPUT DATA: pv1[7]数组中的值是^test8^test8^test8^string[] pv1_7temp = pv1[7].Split('^');
pv1_7temp[0] = "";
string str_temp = "";foreach (string str in pv1_7temp)
{
str_temp += str + "^";
pv1[7] = str_temp;
}输出的结果总是在最后一位多出一个^ = ^test8^test8^test8^^.
请教各位有什么办法只将第一位字符remove,其它的值不变。
Thanks,
变成
test8^test8^test8^ ?
void Main()
{
string a="test8^test9^test10^test11^";
a=string.Join("^",a.Split('^').Skip(1).ToArray());
Console.WriteLine(a.TrimEnd('^')); //test9^test10^test11
}
{
string a="test8^test9^test10^test11^";
a=string.Join("^",a.Split('^').Skip(1).ToArray());
Console.WriteLine(a); //如果想保留最后一个 ^
//test9^test10^test11^
}
void Main()
{
string a="test8^test9^test10^test11^";
Console.WriteLine(a.Substring(a.IndexOf('^')+1));
//test9^test10^test11^
}
str = str.SubString(1);
str= str.Substring(1);
tempStr=tempStr.split(0,tempStr.length-1);//去除最后一位
string tempStr="^test8^test8^test8^^";
tempStr=tempStr.Substring(0,tempStr.length-1);//去除最后一位
thanks, 不过前面少了一个hex ^
我结合你的substring用法fixed.
it will literally remove the first letter, but in my case I need to remove "test" so i guess we will need tempary array here to store all the letters then remove the first value in that array, add the '^' back to the array afterwards and use substring to output the data. Sorry for the confustion cuz I didn't make the statement very clear. But, still thanks for your thought. I am still seeking alternative to make it simple but... still @ learning curve. any input would be greatly appreciated.Thx,
结合Linq一行搞定:str = "^" + string.Join("^", str.Split('^').Skip(1).ToArray())