use*_*138 0 c# string truncate
我有一个字符串列表.它们看起来像:
this.is.the.first.one
that.is.the.second
thishasnopoint
有些人有积分,但有些积分没有积分.我只需要使用c#在可能的第一个点之前从其第一个字母截断字符串.截断的字符串应如下所示:
this
that
thishasnopoint
Google搜索没有向我显示任何有用的线索.
简单的方法是这样的:
string firstBit = wholeString.Split('.')[0];
Run Code Online (Sandbox Code Playgroud)
Split把它变成一个字符串数组,在'.'字符上分开.在这种情况下thishasnopoint,数组只有一个元素.