未知字符串的分离
string ss="aa,bb,cc..."
字符串中ss中有0到n个",",要想把每个以","分隔开的字符串分别提出来并放在一个数组或哈希表中
用C#程序应该怎么写!
这个问题困扰得我好苦,求那位高手给俺帮帮忙吧
------解决方案--------------------ss.Split(",".ToCharArray());
------解决方案--------------------substring() 方法实现!
用法:ss.substring("取的数目","取到的下标位置")
------解决方案--------------------
------解决方案--------------------C# code
string ss = "22,33,44";
string[] splitSs=ss.Split(new Char[] { ',' });
------解决方案--------------------
我这里的names,和emails都是类似于“aa,bb,cc...”
private static Hashtable collateNameEmail(string names, string emails)
{
Hashtable nameEmailList = new Hashtable();
string s = ",";
char[] delimit = s.ToCharArray();
string[] name = names.Split(delimit);
string[] email = emails.Split(delimit);
int count = name.Length;
for (int i = 0; i < count; i++)
{
nameEmailList.Add(email[i], name[i]);
}
return nameEmailList;
}
------解决方案--------------------
------解决方案--------------------
``string[] result = ss.Split(",".ToCharArray());
```substring()+for循环```
``都可以```
```上面一种简单一些```
``
------解决方案--------------------
------解决方案--------------------