我有一个字符串:
10989898 - test1
或另一个例子:
123178239182 - test2
我需要这样的输出:
在第一种情况下:
10989898
在第二种情况下:
123178239182
表示连字符前的值。我怎样才能做到这一点?
最佳答案
string result = theString.Substring(0, theString.IndexOf("-")).Trim();
关于c# - 在连字符前拆分字符串-asp.net C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4795311/