C#一种截取字符串方式

在写代码时经常遇到字符串截取问题,下面是在C#编程中一种不错的截取方式。

string str="A,B,C,D";

string strTemp1=str.Split(new char[] { ',' })[0];

string strTemp2=str.Split(new char[] { ',' })[2];

则结果为

strTemp1 为 A

strTemp2 为 C

原文地址:https://www.cnblogs.com/hailexuexi/p/1786983.html