String.常用的属性方法
2007-03-18 11:43
381 查看
String.ToLower() 方法: 返回此 String 的小写形式的副本。
String.ToUpper() 方法: 返回此 String 的大写形式的副本。
String.TrimEnd() 方法: 从此实例的末尾移除一组指定字符的所有匹配项。。
String.TrimStart() 方法: 从此实例的开始位置移除一组指定字符的所有匹配项。。
String.Trim () 方法: 从此实例的开始位置和末尾移除一组指定字符的所有匹配项。。
String.StartsWith 属性 确定此实例的开始处是否与指定的 String 匹配。
String.EndsWith 属性 确定此实例的末尾是否与指定的 String 匹配。
Label1.Text = "asdfasdf.exe";
Label2.Text = (Label1.Text.EndsWith(".exe")).ToString();
Label3.Text = "asdfasdfasdfexe";
Label4.Text = (Label3.Text.EndsWith(".exe")).ToString();
String.Length 属性 获取此实例中的字符数。
String.IndexOf 属性 在此实例中的第一个匹配项的索引或一个或多个字符的索引。
String.IndexOfAny 属性 报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的索引。
String.LastIndexOfAny 属性 报告在 Unicode 数组中指定的一个或多个字符在此实例中的最后一个匹配项的索引位置。
String.LastIndexOf 指定的 Unicode 字符或 String 在此实例中的最后一个匹配项的索引位置。
Label1.Text = "asd.fasdf.exe";
Label2.Text = (Label1.Text.LastIndexOf(".")).ToString();
String.Substring(int开始位置,int长度) 方法 从此实例检索子字符串。
Label1.Text = "asdfasdf.exe";
Label2.Text = Label1.Text.Substring(Label1.Text.LastIndexOf("."),(Label1.Text.Length-Label1.Text.LastIndexOf("."))).ToString();
String.Replace 将此实例中的指定 Unicode 字符或 String 的所有匹配项替换为其他指定的 Unicode 字符或 String。
Label1.Text = "asdfasdf.exe";
Label2.Text = Label1.Text.Replace("asd","XXX");
String.Remove 方法 从此实例中的指定位置开始删除指定数目的字符。
string.Remove(int 开始删除字符的位置,int 要删除的字符数);
Label1.Text = "asdfasdfa asdf adf asdf asdf asdf asdf asdf asdf asdf asdf .exe";
Label2.Text = Label1.Text.Remove(15,Label1.Text.Length-15)+"...";
String.ToUpper() 方法: 返回此 String 的大写形式的副本。
String.TrimEnd() 方法: 从此实例的末尾移除一组指定字符的所有匹配项。。
String.TrimStart() 方法: 从此实例的开始位置移除一组指定字符的所有匹配项。。
String.Trim () 方法: 从此实例的开始位置和末尾移除一组指定字符的所有匹配项。。
String.StartsWith 属性 确定此实例的开始处是否与指定的 String 匹配。
String.EndsWith 属性 确定此实例的末尾是否与指定的 String 匹配。
Label1.Text = "asdfasdf.exe";
Label2.Text = (Label1.Text.EndsWith(".exe")).ToString();
Label3.Text = "asdfasdfasdfexe";
Label4.Text = (Label3.Text.EndsWith(".exe")).ToString();
String.Length 属性 获取此实例中的字符数。
String.IndexOf 属性 在此实例中的第一个匹配项的索引或一个或多个字符的索引。
String.IndexOfAny 属性 报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的索引。
String.LastIndexOfAny 属性 报告在 Unicode 数组中指定的一个或多个字符在此实例中的最后一个匹配项的索引位置。
String.LastIndexOf 指定的 Unicode 字符或 String 在此实例中的最后一个匹配项的索引位置。
Label1.Text = "asd.fasdf.exe";
Label2.Text = (Label1.Text.LastIndexOf(".")).ToString();
String.Substring(int开始位置,int长度) 方法 从此实例检索子字符串。
Label1.Text = "asdfasdf.exe";
Label2.Text = Label1.Text.Substring(Label1.Text.LastIndexOf("."),(Label1.Text.Length-Label1.Text.LastIndexOf("."))).ToString();
String.Replace 将此实例中的指定 Unicode 字符或 String 的所有匹配项替换为其他指定的 Unicode 字符或 String。
Label1.Text = "asdfasdf.exe";
Label2.Text = Label1.Text.Replace("asd","XXX");
String.Remove 方法 从此实例中的指定位置开始删除指定数目的字符。
string.Remove(int 开始删除字符的位置,int 要删除的字符数);
Label1.Text = "asdfasdfa asdf adf asdf asdf asdf asdf asdf asdf asdf asdf .exe";
Label2.Text = Label1.Text.Remove(15,Label1.Text.Length-15)+"...";
相关文章推荐
- 课后作业(五)String对象的常用属性和方法
- js中String对象和Array对象的常用方法和属性
- String常用方法及属性
- OC总结----类的方法.继承.NSString类的常用方法.NSMutableString 类的方法.数组类.字典类.block语法以及数组排序高级.属性.category (分类,类目).延展,等
- Paint常用方法----SpannableString属性
- 【JS基础回顾】String对象及其常用属性以及方法
- String对象常用方法和属性
- JS教程:String对象及其常用属性以及方法
- TAdvStringGrid控件的一些常用的属性事件和方法
- 第190天:js---String常用属性和方法(最全)
- String常用属性和方法
- js的Prototype属性 解释及常用方法
- String 常用方法
- js的Prototype属性 解释及常用方法
- DOM访问表格子元素的常用属性和方法
- String 类常用方法
- String的一些常用方法
- String常用方法-API
- Java中String,StringBuffer,StringBuilder常用方法及使用实例
- ExtJs 常用方法 属性