C#中System.String类
2017-11-25 11:56
190 查看
C#中System.String类
[b]++System.String类[/b]
++++这个类可以完成很多的常见的任务,如替换字符串、删除空白字符串和把字母变成大写形式等。
++++++[b]Compare[/b]:比较字符串的内容,判断字符串某些字符是否相等。
++++++[b]Contains[/b]:返回一个值,该值只是指定的子串是否出现在字符串中。
++++++[b]Remove[/b]:返回指定数量字符在当前这个实例起始点在已删除的指定的位置的新字符串。
++++++[b]Concat[/b]:把多个字符串实例合并为一个实例。
++++++[b]CopyTo[/b]:把从选定的下标开始的特定数量的字符复制到数组的一个全新实例中。
++++++[b]Format[/b]:格式化包含各种值的字符串和如何格式化每个值的说明符。
++++++[b]IndexOf[/b]:定位字符串中第一次出现某个给定子字符串或字符的位置。
++++++[b]IndexOfAny[/b]:定位字符串中第一次出现某个字符或一组字符的位置。
++++++[b]Insert[/b]:把一个字符串实例插入到另一个字符串实例的指定索引处。
++++++[b]Join[/b]:合并字符串数组,创建一个新的字符串。
++++++[b]LastIndexOf[/b]:与IndexOf一样,但定位最后一次出现的位置。
++++++[b]LastIndexOfAny[/b]:与IndexOfAny一样,但定位最后一次出现的位置。
++++++[b]PadLeft[/b]:在字符串的左侧,通过添加指定的重复字符填充字符串。
++++++[b]PadRight[/b]:在字符串的右侧,通过添加指定的重复字符填充字符串。
++++++[b]Replace[/b]:用另一个字符或子字符串替换字符串中给定的字符或子字符串。
++++++[b]Split[/b]:在出现给定字符的地方,把字符串拆分为一个子字符串数组。
++++++[b]SubString[/b]:在字符串中检索给定位置的子字符串。
++++++[b]ToLower[/b]:把字符串转换为小写形式。
++++++[b]ToUpper[/b]:把字符串转换为大写形式。
++++++[b]Trim[/b]:删除首尾的空白。
++++String类的方法:
--1、[b]public static int
Compare(string strA, string strB)[/b]
比较两个指定的string对象,并返回一个表示它们在排列顺序中相对位置的整数。该方法区分大小写。
--2、[b]public static int
Compare(string strA, string strB, bool ignoreCase)[/b]
比较两个指定的string对象,并返回一个表示它们在排列顺序中相对位置的整数。 但是,如果布尔参数为真时,该方法不区分大小写。
--3、[b]public static string
Concat(string str0, string str1)[/b]
连接两个string对象。
--4、[b]public static string
Concat(stirng str0, string str1, string str2)[/b]
连接三个string对象。
--5、[b]public static string
Concat(string str0, string str1, string str2, string str3)[/b]
连接四个string对象。
--6、[b]public bool
Contains(string value)[/b]
返回一个表示指定string对象是否出现的字符串中的值。
--7、[b]public static string
Copy(string str)[/b]
创建一个与指定字符串具有相同值的新的String对象。
--8、[b]public void
CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)[/b]
从string对象的指定位置开始复制指定数量的字符到Unicode字符数组中的指定位置。
--9、[b]public bool
EndsWith(string value)[/b]
判断string对象的结尾是否匹配指定的字符串。
--10、[b]public bool
Equals(string value)[/b]
判断当前的string对象是否与指定的string对象具有相同的值。
--11、[b]public static bool
Equals(string a, string b)[/b]
判断两个指定的string对象是否具有相同的值。
--12、[b]public static string
Format(string format, Object arg0)[/b]
把指定字符串中一个或多个格式项替换为指定对象的字符串表示形式。
--13、[b]public int
IndexOf(char value)[/b]
返回指定Unicode字符在当前字符串中第一次出现的索引,索引从0开始。
--14、[b]public int
IndexOf(string value)[/b]
返回指定字符串在该实例中第一次出现的索引,索引从0开始。
--15、[b]public int
IndexOf(char value, int startIndex)[/b]
返回指定Unicode字符从该字符串中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--16、[b]public int
IndexOf(string value, int startIndex)[/b]
返回指定字符串从该实例中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--17、[b]public int
IndexOfAny(char[] anyOf)[/b]
返回某一个指定的Unicode字符数组中任意字符在该实例中第一次出现的索引,索引从0开始。
--18、[b]public int
IndexOfAny(char[] anyOf, int startIndex)[/b]
返回某一个指定的Unicode字符数组中任意字符从该实例中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--19、[b]public string
Insert(int startIndex, string value)[/b]
返回一个新的字符串,其中,指定的字符串被插入在当前string对象的指定索引位置。
--20、[b]public static bool
IsNullOrEmpty(string value)[/b]
指示指定的字符串是否为null或者是否为一个空的字符串。
--21、[b]public static string
Join(string separator, string[] value)[/b]
连接一个字符串数组中的所有元素,使用指定的分隔符分隔每个元素。
--22、[b]public static string
Join(string separator, string[] value, int startIndex, int count)[/b]
连接一个字符串数组中指定位置开始的指定元素,使用指定的分隔符分隔每个元素。
--23、[b]public int
LastIndexOf(char value)[/b]
返回指定Unicode字符在当前string对象中最后一次出现的索引位置,索引从0开始。
--24、[b]public int
LastIndexOf(string value)[/b]
返回指定字符串在当前string对象中最后一次出现的索引位置,索引从0开始。
--25、[b]public string
Remove(int startIndex)[/b]
移除当前实例中的所有字符,从指定位置开始,一直到最后一个位置为止,并返回字符串。
--26、[b]public string
Remove(int startIndex, int count)[/b]
从当前字符串的指定位置开始移除指定数量的字符,并返回字符串。
--27、[b]public string
Replace(char oldChar, char newChar)[/b]
把当前string对象中,所有指定的Unicode字符替换为另一个指定的Unicode字符,并返回新的字符串。
--28、[b]public string
Replace(string oldValue, string newValue)[/b]
把当前string对象中,所有指定的字符串替换为另一个指定的字符串,并返回新的字符串。
--29、[b]public string[]
Split(params char[] separator)[/b]
返回一个字符串数组,包含当前的string对象中的子字符串,子字符串是使用指定的Unicode字符数组中的元素进行分割的。
--30、[b]public string[]
Split(char[] separator, int count)[/b]
返回一个字符串数组,包含当前的string对象中的子字符串,子字符串是使用指定的Unicode字符串数组中的元素进行分割的。int参数指定要返回的子字符串的最大数目。
--31、[b]public bool
StartsWith(string value)[/b]
判断字符串实例的开头是否匹配指定的字符串。
--32、[b]public char[]
ToCharArray()[/b]
返回一个带有当前string对象中所有字符的Unicode字符数组。
--33、[b]public char[]
ToCharArray(int startIndex, int length)[/b]
返回一个带有当前string对象中所有字符的Unicode字符数组,从指定的索引开始,直到指定的长度为止。
--34、[b]public string
ToLower()[/b]
把字符串转换为小写并返回。
--35、[b]public string
ToUpper()[/b]
把字符串转换为大写并返回。
--36、[b]public string
Trim()[/b]
移除当前String对象中的所有前导空白字符和后置空白字符。
拓展:StringBuilder类
[b]++StringBuilder类[/b]
++++StringBuilder也有很多常用方法
++++++[b]Append[/b]:给当前字符串追加一个字符串。
++++++[b]AppendFormat[/b]:追加特定格式的字符串。
++++++[b]Insert[/b]:在当前字符串中插入一个子字符串。
++++++[b]Remove[/b]:从当前字符串中删除字符。
++++++[b]Replace[/b]:在当前字符串中,用某个字符(串)替换另一个字符(串)。
++++++[b]ToString[/b]:返回强制转换为System.String对象的字符串。
--_--VRunSoft:lovezuanzuan--_--
[b]++System.String类[/b]
++++这个类可以完成很多的常见的任务,如替换字符串、删除空白字符串和把字母变成大写形式等。
++++++[b]Compare[/b]:比较字符串的内容,判断字符串某些字符是否相等。
++++++[b]Contains[/b]:返回一个值,该值只是指定的子串是否出现在字符串中。
++++++[b]Remove[/b]:返回指定数量字符在当前这个实例起始点在已删除的指定的位置的新字符串。
++++++[b]Concat[/b]:把多个字符串实例合并为一个实例。
++++++[b]CopyTo[/b]:把从选定的下标开始的特定数量的字符复制到数组的一个全新实例中。
++++++[b]Format[/b]:格式化包含各种值的字符串和如何格式化每个值的说明符。
++++++[b]IndexOf[/b]:定位字符串中第一次出现某个给定子字符串或字符的位置。
++++++[b]IndexOfAny[/b]:定位字符串中第一次出现某个字符或一组字符的位置。
++++++[b]Insert[/b]:把一个字符串实例插入到另一个字符串实例的指定索引处。
++++++[b]Join[/b]:合并字符串数组,创建一个新的字符串。
++++++[b]LastIndexOf[/b]:与IndexOf一样,但定位最后一次出现的位置。
++++++[b]LastIndexOfAny[/b]:与IndexOfAny一样,但定位最后一次出现的位置。
++++++[b]PadLeft[/b]:在字符串的左侧,通过添加指定的重复字符填充字符串。
++++++[b]PadRight[/b]:在字符串的右侧,通过添加指定的重复字符填充字符串。
++++++[b]Replace[/b]:用另一个字符或子字符串替换字符串中给定的字符或子字符串。
++++++[b]Split[/b]:在出现给定字符的地方,把字符串拆分为一个子字符串数组。
++++++[b]SubString[/b]:在字符串中检索给定位置的子字符串。
++++++[b]ToLower[/b]:把字符串转换为小写形式。
++++++[b]ToUpper[/b]:把字符串转换为大写形式。
++++++[b]Trim[/b]:删除首尾的空白。
++++String类的方法:
--1、[b]public static int
Compare(string strA, string strB)[/b]
比较两个指定的string对象,并返回一个表示它们在排列顺序中相对位置的整数。该方法区分大小写。
--2、[b]public static int
Compare(string strA, string strB, bool ignoreCase)[/b]
比较两个指定的string对象,并返回一个表示它们在排列顺序中相对位置的整数。 但是,如果布尔参数为真时,该方法不区分大小写。
--3、[b]public static string
Concat(string str0, string str1)[/b]
连接两个string对象。
--4、[b]public static string
Concat(stirng str0, string str1, string str2)[/b]
连接三个string对象。
--5、[b]public static string
Concat(string str0, string str1, string str2, string str3)[/b]
连接四个string对象。
--6、[b]public bool
Contains(string value)[/b]
返回一个表示指定string对象是否出现的字符串中的值。
--7、[b]public static string
Copy(string str)[/b]
创建一个与指定字符串具有相同值的新的String对象。
--8、[b]public void
CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)[/b]
从string对象的指定位置开始复制指定数量的字符到Unicode字符数组中的指定位置。
--9、[b]public bool
EndsWith(string value)[/b]
判断string对象的结尾是否匹配指定的字符串。
--10、[b]public bool
Equals(string value)[/b]
判断当前的string对象是否与指定的string对象具有相同的值。
--11、[b]public static bool
Equals(string a, string b)[/b]
判断两个指定的string对象是否具有相同的值。
--12、[b]public static string
Format(string format, Object arg0)[/b]
把指定字符串中一个或多个格式项替换为指定对象的字符串表示形式。
--13、[b]public int
IndexOf(char value)[/b]
返回指定Unicode字符在当前字符串中第一次出现的索引,索引从0开始。
--14、[b]public int
IndexOf(string value)[/b]
返回指定字符串在该实例中第一次出现的索引,索引从0开始。
--15、[b]public int
IndexOf(char value, int startIndex)[/b]
返回指定Unicode字符从该字符串中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--16、[b]public int
IndexOf(string value, int startIndex)[/b]
返回指定字符串从该实例中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--17、[b]public int
IndexOfAny(char[] anyOf)[/b]
返回某一个指定的Unicode字符数组中任意字符在该实例中第一次出现的索引,索引从0开始。
--18、[b]public int
IndexOfAny(char[] anyOf, int startIndex)[/b]
返回某一个指定的Unicode字符数组中任意字符从该实例中指定字符位置开始搜索第一次出现的索引,索引从0开始。
--19、[b]public string
Insert(int startIndex, string value)[/b]
返回一个新的字符串,其中,指定的字符串被插入在当前string对象的指定索引位置。
--20、[b]public static bool
IsNullOrEmpty(string value)[/b]
指示指定的字符串是否为null或者是否为一个空的字符串。
--21、[b]public static string
Join(string separator, string[] value)[/b]
连接一个字符串数组中的所有元素,使用指定的分隔符分隔每个元素。
--22、[b]public static string
Join(string separator, string[] value, int startIndex, int count)[/b]
连接一个字符串数组中指定位置开始的指定元素,使用指定的分隔符分隔每个元素。
--23、[b]public int
LastIndexOf(char value)[/b]
返回指定Unicode字符在当前string对象中最后一次出现的索引位置,索引从0开始。
--24、[b]public int
LastIndexOf(string value)[/b]
返回指定字符串在当前string对象中最后一次出现的索引位置,索引从0开始。
--25、[b]public string
Remove(int startIndex)[/b]
移除当前实例中的所有字符,从指定位置开始,一直到最后一个位置为止,并返回字符串。
--26、[b]public string
Remove(int startIndex, int count)[/b]
从当前字符串的指定位置开始移除指定数量的字符,并返回字符串。
--27、[b]public string
Replace(char oldChar, char newChar)[/b]
把当前string对象中,所有指定的Unicode字符替换为另一个指定的Unicode字符,并返回新的字符串。
--28、[b]public string
Replace(string oldValue, string newValue)[/b]
把当前string对象中,所有指定的字符串替换为另一个指定的字符串,并返回新的字符串。
--29、[b]public string[]
Split(params char[] separator)[/b]
返回一个字符串数组,包含当前的string对象中的子字符串,子字符串是使用指定的Unicode字符数组中的元素进行分割的。
--30、[b]public string[]
Split(char[] separator, int count)[/b]
返回一个字符串数组,包含当前的string对象中的子字符串,子字符串是使用指定的Unicode字符串数组中的元素进行分割的。int参数指定要返回的子字符串的最大数目。
--31、[b]public bool
StartsWith(string value)[/b]
判断字符串实例的开头是否匹配指定的字符串。
--32、[b]public char[]
ToCharArray()[/b]
返回一个带有当前string对象中所有字符的Unicode字符数组。
--33、[b]public char[]
ToCharArray(int startIndex, int length)[/b]
返回一个带有当前string对象中所有字符的Unicode字符数组,从指定的索引开始,直到指定的长度为止。
--34、[b]public string
ToLower()[/b]
把字符串转换为小写并返回。
--35、[b]public string
ToUpper()[/b]
把字符串转换为大写并返回。
--36、[b]public string
Trim()[/b]
移除当前String对象中的所有前导空白字符和后置空白字符。
拓展:StringBuilder类
[b]++StringBuilder类[/b]
++++StringBuilder也有很多常用方法
++++++[b]Append[/b]:给当前字符串追加一个字符串。
++++++[b]AppendFormat[/b]:追加特定格式的字符串。
++++++[b]Insert[/b]:在当前字符串中插入一个子字符串。
++++++[b]Remove[/b]:从当前字符串中删除字符。
++++++[b]Replace[/b]:在当前字符串中,用某个字符(串)替换另一个字符(串)。
++++++[b]ToString[/b]:返回强制转换为System.String对象的字符串。
--_--VRunSoft:lovezuanzuan--_--
相关文章推荐
- C# 调用System.Data.Sqlite 外键失效解决方案
- C# System.Attribute(验证类)
- C# FileSystemWatcher 在监控文件夹和文件时的用法
- C# 发送电子邮件(含附件)用到的类 system.Net.mail
- C#控制台基础 分析system.console.writeline("hello");的语句成分
- C# 操作注册表 System.UnauthorizedAccessException: 无法写入到注册表项
- C# 配置错误定义了重复的“system.web.extensions/scripting/scriptResourceHandler”节
- C#中 StringBuilder类 与 String类的区别---(转)
- System.String类的Length 属性 和Microsoft.VisualBasic.Len函数的差别
- C# FileSystemWatcher监听文件事件
- ASP.NET 2.0(C#)中System.Web.Caching的应用
- C#中获取当前时间:System.DateTime.Now.ToString()用法
- C#中String类的几个方法(IndexOf、LastIndexOf、Substring)
- C# FileSystemWatcher 监视磁盘文件变更
- C#中String类的几个方法(IndexOf、LastIndexOf、Substring)
- C#基础知识梳理系列十:异常处理 System.Exception
- C# System.Reflection
- LDAP(轻量目录访问协议)基于C#的System.DirectoryServices进行开发
- C#之System.Net类
- C#数组讨论一 System.object [,]与System. object [][]之间的区别