string names = "haha,hello,hehe,Hi";
怎么分割开逗号?
固定4个字符串
现在要实现
string a = haha;
string b = hello;
string names = "haha,hello,hehe,Hi";
怎么分割开逗号?
固定4个字符串
现在要实现
string a = haha;
string b = hello;
string s="haha,hello,hehe,Hi,45,2d,77tf,dfgasd,77"; string[] Arry = s.Split(','); foreach (string a in Arry) { MessageBox.Show(a); }
//我上面说的啰嗦了,这个是比较好的办法。
楼上的方法也太繁琐了吧,要这么曲折
===================================
using System;
namespace ConsoleApplication1 { class Program { public static void Main() {
string delimStr = " , "; char[] delimiter = delimStr.ToCharArray(); string names = "haha,hello,hehe,Hi";
string[] split = null;
split = names.Split(delimiter, 4); foreach (string s in split) { Console.WriteLine("-{0}-", s); } }
} }