码迷,mamicode.com
首页 > Windows程序 > 详细

C# subString的理解

时间:2014-12-03 11:51:37      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:sp   on   bs   ad   ef   nbsp   res   br   字符串   

        public void TestMethod1()
        {
            string str = "ABCDEFGHIJKLMN";

            string result = str.Substring(2); //CDEFGHIJKLMN

            string result1 = str.Substring(2, 3); //CDE

            Console.ReadKey();
            //string result2 = str.Substring();
        }

将subString(index,length)第一个参数看做从0开始的索引,length表示从索引位置截取字段的长度,若不指定长度,则截取字段到字符串末尾。

length的最大长度为str.length-index!

C# subString的理解

标签:sp   on   bs   ad   ef   nbsp   res   br   字符串   

原文地址:http://www.cnblogs.com/Unrmk-LingXing/p/4139517.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!