惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
MyScale Blog
MyScale Blog
Y
Y Combinator Blog
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
N
News and Events Feed by Topic
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
博客园 - 叶小钗
B
Blog
Vercel News
Vercel News
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
Spread Privacy
Spread Privacy
T
Threat Research - Cisco Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Palo Alto Networks Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
Martin Fowler
Martin Fowler
G
GRAHAM CLULEY
Project Zero
Project Zero
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
L
LangChain Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
A
About on SuperTechFans
W
WeLiveSecurity
The GitHub Blog
The GitHub Blog

博客园 - chinachen

查看DLL 版本 平台 x86 x64 MS SQL2008 数据库备份(收集) android 使用sqlite几种方式。 C# 接口 索引 属性 实质及应用 (收集) get set 用法总结 (收集) MVC 资料收集(一) windows运行命令大全 Html:meta标签的奥妙 (收集) - chinachen - 博客园 ASP.NET抓取页面并分析页面数据的研究与探讨。 BlogEngine 深入研究(一) 开篇 ASP.NET实现回调服务器方法 (收集) 统一过程,敏捷过程,微软过程(收集) HTTP服务器状态代码定义(Status Code Definitions)(收集) Lambda 表达式 源自MSDN 多个表 导出EXCEL 代码 (分享) C# 参考之方法参数关键字:params、ref及out (收集) nchar,char,varchar 与nvarchar区别 (收集) - chinachen 抽象类与接口区别 (收集) virtual 与 Abstract 区别
C#中indexof和substring函数用法 (收集) - chinachen - 博客园
chinachen · 2010-03-30 · via 博客园 - chinachen

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