变量
str = "$0,1,2,3,4,5,6,,";
string[] sArray1 = str.Split(new char[2] { '$', ',' });
string[] sArray2 = str.Split(new string[] { "$", "," }, StringSplitOptions.RemoveEmptyEntries);
结果
sArray1 | sArray2 |
---|---|
sArray1[0]: | sArray2[0]:0 |
sArray1[1]:0 | sArray2[1]:1 |
sArray1[2]:1 | sArray2[2]:2 |
sArray1[3]:2 | sArray2[3]:3 |
sArray1[4]:3 | sArray2[4]:4 |
sArray1[5]:4 | sArray2[5]:5 |
sArray1[6]:5 | sArray2[6]:6 |
sArray1[7]:6 | |
sArray1[8]: | |
sArray1[9]: |