11智能在线
新记
c#中如何截取字符中某一符号前的值?例如string str ="23-明城",取-前面的数字。
如题所述
举报该文章
其他看法
第1个回答 推荐于2018-03-14
char[] cutStr=str.split("-");
cutStr[0]即为你需要的值
本回答被网友采纳
第2个回答 2013-05-15
能想到两种办法
1.用 Split 切分
2.int index = str.IndexOf("-")
string result = str.Substring(0,index + 1);本回答被提问者采纳
相似回答
大家正在搜
相关问题
excel中,如果我要取某个特定字符之 前的字段怎么做
C# list<string> 怎么提取需要的内容并存入其他...
c#字符串(字母+数字)累加
c#判断字符串中包含多少个指定字符
C#怎么使一个String型的数组变成字符串
c#如何把string给char赋值
C#比较2个字符串相等,最快的方法是什么?
c#判断字符串中包含多少个逗号