C#中indexof和substring函数用法 (收集)
2010-03-30 13:50
477 查看
C#中indexof和substring函数用法
C#中indexof和substring函数用法
2008-04-01 16:39
indexof() :在字符串中从前向后定位字符和字符串;所有的返回值都是指在字符串的绝对位置,如为空则为- 1
string test="asdfjsdfjgkfasdsfsgfhgjgfjgdddd";
test.indexof('d') =2 //从前向后 定位 d 第一次出现的位置
test.indexof('d',1) =2 //从前向后 定位 d 从第三个字符串 第一次出现的位置
test.indexof('d',5,2) =6 //从前向后 定位 d 从第5 位开始查,查2位,即 从第5位到第7位;
lastindexof() :在字符串中从后向前定位字符和字符串;、
用法和 indexof() 完全相同。
下面介绍 IndexOfAny ||lastindexofany
他们接受字符数组做为变元,其他方法同上,返回数组中任何一个字符最早出现的下标位置
如下
char[] bbv={'s','c','b'};
string abc = "acsdfgdfgchacscdsad";
Response.Write(abc.IndexOfAny(bbv))=1
Response.Write(abc.IndexOfAny(bbv, 5))=9
Response.Write(abc.IndexOfAny(bbv, 5, 3))=9
lastindexofany 同上。
====================================================================
substring() 用法
string a="aadsfdjkfgklfdglfd"
a.substring(5) //截取从第五位以后的所有字符串
a.substring(0,5) //截取从第0位置开始长度为5的字符串
原信息URL:http://www.jiaonan.net/html/blog/1/23464.htm
indexof() :在字符串中从前向后定位字符和字符串;所有的返回值都是指在字符串的绝对位置,如为空则为- 1
string test="asdfjsdfjgkfasdsfsgfhgjgfjgdddd";test.indexof('d') =2 //从前向后 定位 d 第一次出现的位置
test.indexof('d',1) =2 //从前向后 定位 d 从第三个字符串 第一次出现的位置
test.indexof('d',5,2) =6 //从前向后 定位 d 从第5 位开始查,查2位,即 从第5位到第7位;
lastindexof() :在字符串中从后向前定位字符和字符串;、用法和 indexof() 完全相同。
下面介绍 IndexOfAny ||lastindexofany他们接受字符数组做为变元,其他方法同上,返回数组中任何一个字符最早出现的下标位置如下
char[] bbv={'s','c','b'};
string abc = "acsdfgdfgchacscdsad";
Response.Write(abc.IndexOfAny(bbv))=1
Response.Write(abc.IndexOfAny(bbv, 5))=9
Response.Write(abc.IndexOfAny(bbv, 5, 3))=9lastindexofany 同上。====================================================================
substring() 用法
string a="aadsfdjkfgklfdglfd"a.substring(5) //截取从第五位以后的所有字符串
a.substring(0,5) //截取从第0位置开始长度为5的字符串
原信息URL:http://www.jiaonan.net/html/blog/1/23464.htm
C#中indexof和substring函数用法
2008-04-01 16:39
indexof() :在字符串中从前向后定位字符和字符串;所有的返回值都是指在字符串的绝对位置,如为空则为- 1
string test="asdfjsdfjgkfasdsfsgfhgjgfjgdddd";
test.indexof('d') =2 //从前向后 定位 d 第一次出现的位置
test.indexof('d',1) =2 //从前向后 定位 d 从第三个字符串 第一次出现的位置
test.indexof('d',5,2) =6 //从前向后 定位 d 从第5 位开始查,查2位,即 从第5位到第7位;
lastindexof() :在字符串中从后向前定位字符和字符串;、
用法和 indexof() 完全相同。
下面介绍 IndexOfAny ||lastindexofany
他们接受字符数组做为变元,其他方法同上,返回数组中任何一个字符最早出现的下标位置
如下
char[] bbv={'s','c','b'};
string abc = "acsdfgdfgchacscdsad";
Response.Write(abc.IndexOfAny(bbv))=1
Response.Write(abc.IndexOfAny(bbv, 5))=9
Response.Write(abc.IndexOfAny(bbv, 5, 3))=9
lastindexofany 同上。
====================================================================
substring() 用法
string a="aadsfdjkfgklfdglfd"
a.substring(5) //截取从第五位以后的所有字符串
a.substring(0,5) //截取从第0位置开始长度为5的字符串
原信息URL:http://www.jiaonan.net/html/blog/1/23464.htm
indexof() :在字符串中从前向后定位字符和字符串;所有的返回值都是指在字符串的绝对位置,如为空则为- 1
string test="asdfjsdfjgkfasdsfsgfhgjgfjgdddd";test.indexof('d') =2 //从前向后 定位 d 第一次出现的位置
test.indexof('d',1) =2 //从前向后 定位 d 从第三个字符串 第一次出现的位置
test.indexof('d',5,2) =6 //从前向后 定位 d 从第5 位开始查,查2位,即 从第5位到第7位;
lastindexof() :在字符串中从后向前定位字符和字符串;、用法和 indexof() 完全相同。
下面介绍 IndexOfAny ||lastindexofany他们接受字符数组做为变元,其他方法同上,返回数组中任何一个字符最早出现的下标位置如下
char[] bbv={'s','c','b'};
string abc = "acsdfgdfgchacscdsad";
Response.Write(abc.IndexOfAny(bbv))=1
Response.Write(abc.IndexOfAny(bbv, 5))=9
Response.Write(abc.IndexOfAny(bbv, 5, 3))=9lastindexofany 同上。====================================================================
substring() 用法
string a="aadsfdjkfgklfdglfd"a.substring(5) //截取从第五位以后的所有字符串
a.substring(0,5) //截取从第0位置开始长度为5的字符串
原信息URL:http://www.jiaonan.net/html/blog/1/23464.htm
相关文章推荐
- C#中indexof和substring函数用法
- C#中indexof和substring函数用法
- C#中indexof和substring函数用法 (截取字符串)
- C# indexof和substring()用法
- JAVA中indexOf函数用法和subString()方法
- C# Winform SubString()函数的用法
- js字符串截取函数slice()、substring()、substr()以及split()、John() 、indexOf()的用法
- mysql 的函数用法SUBSTRING_INDEX
- string里的IndexOf、LastIndexOf、Substring的详解(意义和用法)
- string里的IndexOf、LastIndexOf、Substring的详解(意义和用法)
- IndexOf、LastIndexOf、Substring的用法
- C#字符串的截取函数用法总结
- js中substr,substring,indexOf,lastIndexOf,split 的用法
- Mysql字符串截取函数SUBSTRING的用法说明
- Mysql字符串截取函数SUBSTRING的用法说明
- Mysql字符串截取函数SUBSTRING的用法说明
- C#常用函数收集
- Mysql字符串截取函数SUBSTRING的用法说明
- Mysql字符串截取函数SUBSTRING的用法说明
- C#中String类的几个方法(IndexOf、LastIndexOf、Substring)