从字符串的结尾删除多个字符类型 [英] Remove multiple char types from end of string
本文介绍了从字符串的结尾删除多个字符类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个建立了地址字段循环,有些字段可能在字符串的结尾是空的。
清单<串GT;名单=新名单,LT;串>();
//列表可以包含任何数量的值,其中一些可能是(空字符串)
串的returnValue =;
为(INT iRow = 1; iRow< = list.Count; iRow ++)
+的returnValue =的String.Format({0},列表[iRow]);
=的returnValue returnValue.Trim();
我的输出是
ASD,AAA,QWE,123123,,,,,
我怎么能从字符串中删除尾随,
解决方案
=的returnValue returnValue.TrimEnd( '','');
I have a loop that builds up address fields, some of these fields may be empty at the end of the string
List<string> list = new List<string>();
//list can contain any number of values, some of which might be "" (empty string)
string returnValue = "";
for (int iRow = 1; iRow <= list.Count; iRow++)
returnValue += String.Format("{0}, ", list[iRow]);
returnValue = returnValue.Trim();
my output is
asd, aaa, qwe, 123123, , , , ,
How can i remove the trailing ", " from the string?
解决方案
returnValue = returnValue.TrimEnd(' ', ',');
这篇关于从字符串的结尾删除多个字符类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文