String.trim()、.contains()等的作用

A.String.trim()

假设有一个字符串" ddd dd d ",经过Trim()之后成为"ddd dd d",如上只去掉两边多余的空格(包括制表符)。

B.String.contains("D")类型

判断String 字符串里是否包含D字符串,返回的是Boolean

C.String.Substring(0,i);

1 取字符串的前i个字符

str=str.Substring(0,i); // or str=str.Remove(i,str.Length-i);

2 去掉字符串的前i个字符:

str=str.Remove(0,i); // or str=str.Substring(i); 

3 从右边开始取i个字符:

str=str.Substring(str.Length-i); // or str=str.Remove(0,str.Length-i); 

4 从右边开始去掉i个字符:

str=str.Substring(0,str.Length-i); // or str=str.Remove(str.Length-i,i);
What do you want to be?
原文地址:https://www.cnblogs.com/CatsBlog/p/9176039.html