例如 string s1="123.456.789",想截取得到的新字符串为“789”

代码如下:

            string s1 = "123.456.789";
            string s2 = string.Empty;
            //先求出最后出现这个字符的下标
            int index = s1.LastIndexOf('.');
            //从下一个索引开始截取
            s2=s1.Substring(index+1);
            Console.WriteLine(s2);
            Console.ReadLine();

 

相关文章:

  • 2022-12-23
  • 2022-02-09
  • 2021-07-28
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案