C#中System.String类
来源:互联网 发布:报考东华大学网络教育 编辑:程序博客网 时间:2024/06/05 21:09
C#中System.String类
++System.String类
++++这个类可以完成很多的常见的任务,如替换字符串、删除空白字符串和把字母变成大写形式等。
++++++Compare:比较字符串的内容,判断字符串某些字符是否相等。
++++++Contains:返回一个值,该值只是指定的子串是否出现在字符串中。
++++++Remove:返回指定数量字符在当前这个实例起始点在已删除的指定的位置的新字符串。
++++++Concat:把多个字符串实例合并为一个实例。
++++++CopyTo:把从选定的下标开始的特定数量的字符复制到数组的一个全新实例中。
++++++Format:格式化包含各种值的字符串和如何格式化每个值的说明符。
++++++IndexOf:定位字符串中第一次出现某个给定子字符串或字符的位置。
++++++IndexOfAny:定位字符串中第一次出现某个字符或一组字符的位置。
++++++Insert:把一个字符串实例插入到另一个字符串实例的指定索引处。
++++++Join:合并字符串数组,创建一个新的字符串。
++++++LastIndexOf:与IndexOf一样,但定位最后一次出现的位置。
++++++LastIndexOfAny:与IndexOfAny一样,但定位最后一次出现的位置。
++++++PadLeft:在字符串的左侧,通过添加指定的重复字符填充字符串。
++++++PadRight:在字符串的右侧,通过添加指定的重复字符填充字符串。
++++++Replace:用另一个字符或子字符串替换字符串中给定的字符或子字符串。
++++++Split:在出现给定字符的地方,把字符串拆分为一个子字符串数组。
++++++SubString:在字符串中检索给定位置的子字符串。
++++++ToLower:把字符串转换为小写形式。
++++++ToUpper:把字符串转换为大写形式。
++++++Trim:删除首尾的空白。
++++String类的方法:
--1、public static intCompare(string strA, string strB)
比较两个指定的string对象,并返回一个表示它们在排列顺序中相对位置的整数。该方法区分大小写。
--2、public static int Compare(string strA, string strB, bool ignoreCase)
比较两个指定的string对象,并返回一个表示它们在排列顺序中相对位置的整数。 但是,如果布尔参数为真时,该方法不区分大小写。
--3、public static string Concat(string str0, string str1)
连接两个string对象。
--4、public static string Concat(stirng str0, string str1, string str2)
连接三个string对象。
--5、public static string Concat(string str0, string str1, string str2, string str3)
连接四个string对象。
--6、public boolContains(string value)
返回一个表示指定string对象是否出现的字符串中的值。
--7、public static stringCopy(string str)
创建一个与指定字符串具有相同值的新的String对象。
--8、public voidCopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)
从string对象的指定位置开始复制指定数量的字符到Unicode字符数组中的指定位置。
--9、public boolEndsWith(string value)
判断string对象的结尾是否匹配指定的字符串。
--10、public boolEquals(string value)
判断当前的string对象是否与指定的string对象具有相同的值。
--11、public static boolEquals(string a, string b)
判断两个指定的string对象是否具有相同的值。
--12、public static stringFormat(string format, Object arg0)
把指定字符串中一个或多个格式项替换为指定对象的字符串表示形式。
--13、public int IndexOf(char value)
返回指定Unicode字符在当前字符串中第一次出现的索引,索引从0开始。
--14、public int IndexOf(string value)
返回指定字符串在该实例中第一次出现的索引,索引从0开始。
--15、public int IndexOf(char value, int startIndex)
返回指定Unicode字符从该字符串中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--16、public intIndexOf(string value, int startIndex)
返回指定字符串从该实例中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--17、public intIndexOfAny(char[] anyOf)
返回某一个指定的Unicode字符数组中任意字符在该实例中第一次出现的索引,索引从0开始。
--18、public int IndexOfAny(char[] anyOf, int startIndex)
返回某一个指定的Unicode字符数组中任意字符从该实例中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--19、public stringInsert(int startIndex, string value)
返回一个新的字符串,其中,指定的字符串被插入在当前string对象的指定索引位置。
--20、public static bool IsNullOrEmpty(string value)
指示指定的字符串是否为null或者是否为一个空的字符串。
--21、public static stringJoin(string separator, string[] value)
连接一个字符串数组中的所有元素,使用指定的分隔符分隔每个元素。
--22、public static string Join(string separator, string[] value, int startIndex, int count)
连接一个字符串数组中指定位置开始的指定元素,使用指定的分隔符分隔每个元素。
--23、public intLastIndexOf(char value)
返回指定Unicode字符在当前string对象中最后一次出现的索引位置,索引从0开始。
--24、public int LastIndexOf(string value)
返回指定字符串在当前string对象中最后一次出现的索引位置,索引从0开始。
--25、public string Remove(int startIndex)
移除当前实例中的所有字符,从指定位置开始,一直到最后一个位置为止,并返回字符串。
--26、public stringRemove(int startIndex, int count)
从当前字符串的指定位置开始移除指定数量的字符,并返回字符串。
--27、public string Replace(char oldChar, char newChar)
把当前string对象中,所有指定的Unicode字符替换为另一个指定的Unicode字符,并返回新的字符串。
--28、public string Replace(string oldValue, string newValue)
把当前string对象中,所有指定的字符串替换为另一个指定的字符串,并返回新的字符串。
--29、public string[] Split(params char[] separator)
返回一个字符串数组,包含当前的string对象中的子字符串,子字符串是使用指定的Unicode字符数组中的元素进行分割的。
--30、public string[]Split(char[] separator, int count)
返回一个字符串数组,包含当前的string对象中的子字符串,子字符串是使用指定的Unicode字符串数组中的元素进行分割的。int参数指定要返回的子字符串的最大数目。
--31、public boolStartsWith(string value)
判断字符串实例的开头是否匹配指定的字符串。
--32、public char[] ToCharArray()
返回一个带有当前string对象中所有字符的Unicode字符数组。
--33、public char[]ToCharArray(int startIndex, int length)
返回一个带有当前string对象中所有字符的Unicode字符数组,从指定的索引开始,直到指定的长度为止。
--34、public string ToLower()
把字符串转换为小写并返回。
--35、public stringToUpper()
把字符串转换为大写并返回。
--36、public stringTrim()
移除当前String对象中的所有前导空白字符和后置空白字符。
拓展:StringBuilder类
++StringBuilder类
++++StringBuilder也有很多常用方法
++++++Append:给当前字符串追加一个字符串。
++++++AppendFormat:追加特定格式的字符串。
++++++Insert:在当前字符串中插入一个子字符串。
++++++Remove:从当前字符串中删除字符。
++++++Replace:在当前字符串中,用某个字符(串)替换另一个字符(串)。
++++++ToString:返回强制转换为System.String对象的字符串。
--_--VRunSoft:lovezuanzuan--_--
- C#中System.String类
- c#中string和System.String的区别
- C# System.DBNull string
- c#中System.IO类
- MATLAB中System.string格式数据获取,MATLAB调用C#中的dll输出数据格式问题
- C#中String与string
- C#中String类的几个方法
- c#中string类的一些用法
- C#中String类方法汇总
- C#中String类常用的方法
- C#中String类方法汇总
- c#中string类方法汇总
- C#中String类方法汇总
- c#中不能继承String类
- C#中String类的简单应用
- C#中System.BadImageFormatException解决
- java中System.getProperty(String key);
- C#中System.Threading.Thread类及其线程睡眠代码
- Linux/mac环境下启动Tomcat
- 解决移动端overflow:scroll元素内部1px元素不显示方法
- 防卫导弹问题
- 图像分割学习小结
- mongo eval方法执行需要认证解决办法
- C#中System.String类
- 我的物联网项目(十四) 分布式事务
- Centos7 安装 PHP7最新版的详细教程
- 测试在vue下点击事件传参和不传参的区别
- 设计模式【服务器定位模式Service Locator Pattern】
- 6.1 使用接口
- 007-100-判断两个二叉树是否相等 Same Tree
- k近邻法
- unity 安卓 如何读取 Application.persistentDataPath这个路径下面的assetbundle文件