namespace index
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string s = "abcdefghijklmn";
                int i = s.IndexOf("f"); // i是f在字符串s中的位置,这里为5,注意开始位置是0而不是1
                Console.WriteLine(i);
                string j = s.Substring(i,4);  //从第i位开始截取4个字符 (注意初始位置为0)
                Console.WriteLine(j);
                Console.ReadLine();
            }
        }
    }
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-09-06
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-20
  • 2022-12-23
  • 2021-08-30
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案