subString 在C#中的作用是什么

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/10 04:15:18

subString 在C#中的作用是什么
subString 在C#中的作用是什么

subString 在C#中的作用是什么
从此实例检索子字符串.子字符串从指定的字符位置开始且具有指定的长度.
public string Substring(
int startIndex,
int length
)
参数
startIndex
类型: System ..::.Int32
此实例中子字符串的起始字符位置(从零开始).
length
类型: System ..::.Int32
子字符串中的字符数.
String str1 = "abcdefg";
str1.Substring(2,3); //返回从第3个字符开始的长度为3的子字符串,结果是字符串"cde"