效果
代码
cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleAppNumberOneHelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("hello world!2020Year!");
#region 2 截取字符串方法
//
string originalString = "Hello, World!";
string truncatedString = originalString.Substring(0, 5); // 截取从索引0开始的5个字符; 会获取到Hello内容打印出来; 8.31
Console.WriteLine(truncatedString);
//截取前6个字符;
string sixS = originalString.Substring(0, 6);
Console.WriteLine(sixS);
//W1
string str = "业务为先,代码再写的顺序,才是正确的写代码入门的方式所在,以至于进阶所在!";
string waterStr2 = str.Substring(0, 12);
Console.WriteLine(waterStr2);
#endregion
Console.ReadLine();
}
}
}