Files
freeCodeCamp/guide/chinese/csharp/substring/index.md
2018-10-16 21:32:40 +05:30

25 lines
520 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Substring
localeTitle: 子
---
# 子
`Substring`提取字符串值的一部分。它与2个整数参数一起使用第一个是第一个字符的位置以索引0开头第二个是所需的字符长度。
## 例
```
string firstSentence = "Apple, I have.";
string secondSentence = "I have a Pen.";
string apple = firstSentence.Substring(0,5);
string pen = secondSentence.Substring(9,3);
Console.WriteLine(apple);
Console.WriteLine(pen);
```
## 输出:
```
>Apple
>Pen
```