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

推荐订阅源

博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AI
AI
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Y
Y Combinator Blog
P
Palo Alto Networks Blog
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
B
Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 热门话题
Cisco Talos Blog
Cisco Talos Blog
IT之家
IT之家
Engineering at Meta
Engineering at Meta
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
F
Fortinet All Blogs
Jina AI
Jina AI
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
GbyAI
GbyAI
L
LangChain Blog
P
Privacy International News Feed
Martin Fowler
Martin Fowler
The GitHub Blog
The GitHub Blog
Project Zero
Project Zero
TaoSecurity Blog
TaoSecurity Blog
A
About on SuperTechFans
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
GRAHAM CLULEY
I
InfoQ
K
Kaspersky official blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Troy Hunt's Blog
博客园_首页
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
I
Intezer
博客园 - 聂微东

博客园 - 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