日期:2014-05-18 浏览次数:21469 次
public Hashtable GetGroup(string Source)
{
Hashtable Group = new Hashtable { };
string[] GroupArr = Source.Split(';'); //根据字符串分组
Array.ForEach(GroupArr, group =>
{
if (!string.IsNullOrEmpty(group))
{
string[] groupArr = group.Split('|'); //根据字符串分组员
Hashtable Element = new Hashtable { };
for (int i = 1; i < groupArr.Count(); i++)
{
if (!string.IsNullOrEmpty(groupArr[i]))
{
string[] ElementArr = groupArr[i].Split(':'); //根据字符串分组员状态
Element.Add(int.Parse(ElementArr[0]), ElementArr[1]);
}
}
Group.Add(int.Parse(groupArr[0]), Element);
}
});
return Group;
}
public List<List<string>> GetGroup()
{
string Source1 = "5|5:1|4:1|3:1|2:0|1:1;4|5:1|4:1|1:0;3|4:0|2:1|1:1;2|2:1|1:0;1|5:1|3:0";
string Source2 = "5|5:0|3:1|2:1;4|4:1;3|3:1;2|2:1;1|5:1|4:0";
List<List<string>> Group = new List<List<string>>();
string[] GroupArr = Source1.Split(';'); //根据字符串分组
var sp1 = Source1.Split(new char[] { ';', '|' });
var sp2 = Source2.Split(new char[] { ';', '|' });
var sp3 = sp1.Concat(sp2).Distinct().ToList();
Group.Add(sp3);
//Array.ForEach(GroupArr, group =>
//{
// if (!string.IsNullOrEmpty(group))
// {
// string[] groupArr = group.Split('|'); //根据字符串分组员
// Hashtable Element = new Hashtable { };
// for (int i = 1; i < groupArr.Count(); i++)
// {
// if (!string.IsNullOrEmpty(groupArr[i]))
// {
// string[] ElementArr = groupArr[i].Split(':'); //根据字符串分组员状态
// Element.Add(int.Parse(ElementArr[0]), ElementArr[1]);
// }
// }
// Group.Add(int.Parse(groupArr[0]), Element);
// }
//});
return Group;
}
------解决方案--------------------
一看这个分数就知道我只能是进来学习的。。。
------解决方案--------------------