C# sring.remove()方法的使用

//函数定义
public String Remove(int startIndex);
public String Remove(int startIndex, int count);
            string s1 = "我喜欢的二哈";
            //移除从索引1开始到字符串末尾的字符(包括索引1本身)
            string s2 = s1.Remove(1); 
            //移除从索引1开始之后的两个字符(包括索引1本身)
            string s3 = s1.Remove(1, 2);
            Console.WriteLine(s2);
            Console.WriteLine(s3);
            Console.ReadLine();
            //实例结果为:
            //我
            //我的二哈

 


版权声明:本文为qq_41387975原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。