C#中如何子字符串示例

string sentence = "Onitroad.com a tutorial website for info-technology.";

Console.WriteLine("Oroirnal String: {0}", sentence);

Console.WriteLine("Substring starting at 20: {0}", sentence.Substring(20));

Console.WriteLine("Substring starting at 20, next 10 chars: {0}", sentence.Substring(20, 10));
C#子字符串

在本文中,我们将讨论如何在C#中使用子字符串。

子字符串是字符串的一部分。
子字符串方法从以指定位置开始从字符串检索子字符串。

在c#中,Substring 方法有两种重载形式:

第一个形式只需要一个整数作为子字符串的起始位置,并返回其余的字符串。
第二种形式将第一整数作为起始位置和第二整数作为子字符串的长度。

日期:2020-04-11 22:50:25 来源:oir作者:oir