假设我需要像这样分割字符串:
输入字符串:“我的.名称.是Bond._James键!”输出2个字符串:
我试过这个:
int lastDotIndex = inputString.LastIndexOf(".", System.StringComparison.Ordinal);
string firstPart = inputString.Remove(lastDotIndex);
string secondPart= inputString.Substring(lastDotIndex + 1, inputString.Length - firstPart.Length - 1);有人能提出更优雅的方式吗?
发布于 2014-02-12 16:44:12
https://stackoverflow.com/questions/21733756
复制相似问题