前几天仔细学习了string函数的用法 做了个总结结
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test_01
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "123456789078ABab你好吗";
            Console.WriteLine(str.IndexOf('0')); //数字0的索引是9
            Console.WriteLine(str.IndexOf("4"));//数字4的索引是3
            Console.WriteLine(str.IndexOf('0', 4));//从索引为4的数字开始一次查找0
            Console.WriteLine(str.CompareTo("你好吗"));//比较两个字符串是否相等,相等返回0
            char []b={'7','5','8','6','9'};
            Console.WriteLine(str.IndexOfAny(b).ToString());//报告指定 b数组中的任意字符在str此中第一个匹配项的索引此时表示'5'在str中的索引为4
             str.Contains(str1);//判断str是否包含str1
            if (str.Contains("你好不"))
            {
                Console.WriteLine(str);
            }
            else
                Console.WriteLine("不包含");
 
            str.CopyTo(8, a, 1, 2);//从字符串str的索引为8的字符开始复制2个字符到数组a中(从数组的索引为1的数开始)
            char [] a={'1','2','3','4'};      
           
            foreach (char b in a)
            {
                Console.WriteLine(b.ToString ());
            }

            //确定 String 的实例的末尾是否与指定的字符串匹配
            if (str.EndsWith("吗"))
            {
                Console.WriteLine("包含");
            }
            else
                Console.WriteLine("不包含");
 
             insert ;//在此实例中的指定索引位置插入一个指定的 String 实例
             Console .WriteLine ( str.Insert(3, "圭贤"));//在str索引为3的地方插入字符串圭贤
            string.Intern(str);//检索系统对指定 String 的引用
            string.IsInterned(str);//检索对指定 String 的引用
            string.IsNullOrEmpty(str);//指示指定的 String 对象是 nullNothingnullptrnull 引用(在 Visual Basic 中为 Nothing) 还是 Empty 字符串。
            Console .WriteLine ( string.IsNullOrEmpty(str));
            string.Join();
 
            str.LastIndexOf();// 报告指定的 Unicode 字符或 String 在此实例中的最后一个匹配项的索引位置。
            Console .WriteLine ( str .LastIndexOf ( '7'));//报告在str中与7匹配的最后一个字符串的索引
            Console.WriteLine(str.LastIndexOf("7"));
            str.LastIndexOfAny();//报告在 Unicode 数组中指定的一个或多个字符在此实例中的最后一个匹配项的索引位置
            char[] c = { '5', '好', '8' };
            Console.WriteLine(str.LastIndexOfAny(c));//数组c中的元素在str中的最后一个匹配项的索引位置
            Console.WriteLine(str.LastIndexOfAny(c,3));
 
            //已右对齐此实例中的字符,在左边用空格或指定的 Unicode 字符填充以达到指定的总长度
            Console.WriteLine(str.PadLeft(30));
            Console .WriteLine ( str .PadLeft (30,'不'));
            //左对齐此字符串中的字符,在右边用空格或指定的 Unicode 字符填充以达到指定的总长度。
            Console.WriteLine(str.PadRight(30));
            Console.WriteLine(str .PadRight (30,'不'));
            //从此实例中删除指定个数的字符
            Console.WriteLine(str.Remove(3, 5));
 
            str.Replace();// 将此实例中的指定 Unicode 字符或 String 的所有匹配项替换为其他指定的 Unicode 字符或 String。
            Console.WriteLine(str .Replace('1','b'));
            Console.WriteLine(str.Replace("1", "b"));
            str.Split();
            Console.WriteLine ( str.StartsWith("123"));
            Console.WriteLine(str.Substring(3, 4));//从此实例检索子字符串
            str.ToCharArray(2, 6);//将此实例中的字符复制到 Unicode 字符数组。
 
            foreach (char b in c)
            {
                Console.WriteLine(c.ToString());
            }
            Console.WriteLine(str.ToLower());//返回此 String 转换为小写形式的副本
            Console.WriteLine(str.ToUpper());//返回此 String 转换为大写形式的副本
            str.TrimEnd();//从当前 String 对象移除数组中指定的一组字符的所有尾部匹配项
            str.TrimStart();//从当前 String 对象移除数组中指定的一组字符的所有前导匹配项
            str.Trim();//从当前 String 对象移除一组指定字符的所有前导匹配项和尾部匹配项。

        }
    }
}