如何从字符串中删除结尾逗号 [英] how to remove end comma from the string
本文介绍了如何从字符串中删除结尾逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public string display()
{
string st="";
DataTable dt= (DataTable)ViewState["CurrentData"];
for (int i = 0; i < dt.Rows.Count ; i++)
{
st += dt.Rows[i]["item"].ToString() + ",";
}
return st;
}
这是我的函数,它以字符串格式存储值
例如:-abc @ gmail.com,xya @ yahoo.com,dfd @ gmail.com,
如何从字符串中删除最后一个逗号
例如:-abc @ gmail.com,xya @ yahoo.com,dfd @ gmail.com
请帮我...
This is my function who stores values in string format
for eg:- abc@gmail.com,xya@yahoo.com,dfd@gmail.com,
How can i remove the last comma from the string
for eg:- abc@gmail.com,xya@yahoo.com,dfd@gmail.com
Pls help me...
推荐答案
string finalvalue = string.Empty;
finalvalue = lblSelected.Text.Substring(0, lblSelected.Text.Length - 1);
谢谢
Ashish
Thanks
Ashish
st = st.Remove(st.Length-1,1);
st = st.Remove(st.Length - 1, 1);
st = st.Substring(0,st.Length- 1);
st=st.Substring(0,st.Length-1);
这篇关于如何从字符串中删除结尾逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文