Substring() usage of String class

Substring(a,b) intercepts b numbers after the first a of the string, where the initial start is the first number, and a<string.Length cannot exceed the maximum length of the string

It is easy to understand directly by looking at the code

static void Main(string[] args)
        {

            //先定义一个字符串

           string s= "我爱学习,学习爱我";

           //从第一个我字后面开始,截取四个,即爱学习,

            Console.WriteLine(s.Substring(1,4));

            Console.ReadKey();

       }

       

Look at the output value love learning 

Guess you like

Origin blog.csdn.net/m0_52608003/article/details/127061504