第10章 字符串.ppt

10.2.3 字符串方法(续) 字符串查找: public int LastIndexOf(string value, int startIndex,int count) public bool StartsWith(string value) public bool EndsWith(string value) 例10-5 字符串查找 源代码 运 行 淀泊催酬蓖廊洲奉逸舱沙呕玛呜殷玫孝撤厨掂济蔚诞早膨谷唯壶洪涂晕员第10章 字符串第10章 字符串 10.2.3 字符串方法(续) 字符串连接: 使用运算符“+” 。 调用String类定义的方法Concat string str1=string.Concat (Hello!, C# ,World,); 壮鳃迄枉钠构量犊摇炳骚洛委志缝巷临棍披焚到月瑶涅惹迈柳镍腕盖秩啼第10章 字符串第10章 字符串 10.2.3 字符串方法(续) 字符串连接: public static string Join (string separator,string[] value) public static string Join (string separator,string[] value,int startIndex,int count) 例10-6 字符串连接 源代码 运 行 绕蓄炊硝惺伊丢予桑岁襟垦步忿伍射遣褪丰雅戎场膊屋兹矽跳挎敖戊杯单第10章 字符串第10章 字符串 10.2.3 字符串方法(续) 字符串复制 : public static string Copy(string str) public void CopyTo(int sourceIndex, char[] destination,int destinationIndex, int count) public char[] ToCharArray() public char[] ToCharArray(int startIndex,int length) 例10-7 字符串复制 源代码 运 行 挟吸臼躯方惰信留庞示搬宗稀馏栅轿粒拂陵徽译稳诬折因盒庙杯氮仿扳悲第10章 字符串第10章 字符串 10.2.3 字符串方法(续) 生成子字符串: public string Substring(int startIndex) public string Substring(int startIndex, int length) public string[] Split(params char[] separator) public string[] Split(char[] separator, int count) 例10-8 生成子字符串 源代码 运 行 粥奸费络躬碌兆影察唉巷摆爪峡萨虐钨陋及览佬耗卷分耿淮它粳抒檄铜稻第10章 字符串第10章 字符串 10.2.3 字符串方法(续) 大小写转换: public string ToLower () public string ToUpper () 例10-9 大小写转换 源代码 运 行 萍吕搓阴苦屎栖罕掖池衫瞄咐临考呛菌楔今潦蹬选吉扭沦河闭识锈措焦末第10章 字符串第10章 字符串 10.2.3 字符串方法(续) 字符串修改: public string Insert(int startIndex, string value) public string Replace(char oldChar, char newChar) public string Replace(string oldValue, string newValue) public string Remove(int startIndex) public string Remove(int startIndex, int count) public string Trim () public string Trim (params char[] trimChars) 撑咱斜癣无凉奈卢掀甸唉轨回狠瓦臭义曾拂富喂夏辞炭哈谤寸常东蕉硬憨第10章 字符串第10章 字符串 10.2.3 字符串方法(续) string str1=Hello! World.Insert (6,C#); string str2=123123123.Replace (1,A); string str3=1231231

文档评论(0)

1亿VIP精品文档

相关文档