在字串處理上我們經過會遇到需要把字串進行切割,再做後續的處理,這時候我們就會使用到 Split 這個指令進行操作,下面介紹操作的方法
RESULT
SAMPLE CODE
string str = "a,b,c,d,e,f,g,h,i"; string[] dataArrary = str.Split(','); Console.WriteLine("分割前"); Console.WriteLine(str); Console.WriteLine("分割後"); foreach (string i in dataArrary) Console.WriteLine(i.ToString()); Console.ReadLine();