可以使用字符串的Split方法将字符串按照指定的分隔符分割成字符串数组,然后取数组的最后一个元素即可。

示例代码:

string str = "abc/def/ghi/jkl";
string[] arr = str.Split('/');
string last = arr[arr.Length - 1];
Console.WriteLine(last);  // 输出 jkl
c# 分割字符串取最后一段

原文地址: https://www.cveoy.top/t/topic/f4D3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录