110,545
社区成员
发帖
与我相关
我的任务
分享
public static List<Model > connectModel = new List<Model >();//验证成功后进行保存ConInstance对象和configNum
//Model{
//ConInstance CI{get;set;}
//string str{get;set}
//用于判断ConInstance 对象是否能通过验证,需要和configNum进行匹配
public static int DoWork(ConInstance ci)
{
string[] configNum = { "1", "2","3" };
if (succeedList.Count == 0)//还未成功验证
{
foreach (string one in configNum)
{
if (Login(one, ci) == true)//是否能验证成功
{
People p = new People (one);
succeedList.Add(p);//保存一个people对象
connectModel.Add(new Model { CI=ci,str=one});
}
}
return succeedList.Count;
}
else//验证个数>0,并且对已经保存的进行重新验证
{
int count = 0;
foreach (string one in configNum )
{
bool ishave = false;
foreach (People p in succeedList)
{
if (p.peopleNum == one)
{
ConInstance ci = connectModel.FirstOrDefault(s => s.str == one).CI;
if (Login(one, ci) == true)
{
count++;
}
ishave = true;
break;
}
}
if (ishave == false)
{
if (Login(one, ci) == true)
{
People p = new People (one);
succeedList.Add(p);//保存一个people对象
connectModel.Add(new Model { CI=ci,str=one});
count++;
}
}
}
return count;
}
}
List<User> ulist = new List<User>();
User u = new User();
u.id = 1;
u.name = "1";
ulist.Add(u);
User u2 = u;
u2.name = "2";
ulist.Add(u2);
//到这里为止,ulist中 的u和u1的name都是2
//如果是这么添加,就没问题了。
User u3 = new User();
u3.id = 2;
u3.name = "3";
ulist.Add(u3);
Console.ReadLine();
public class User
{
public int id { get; set; }
public string name { get; set; }
public string type { get; set; }
public int value { get; set; }
}
public static int DoWork(ConInstance ci)
{
……
ConInstance ci = ……
……
}
不可能出现这种代码
楼主要是很闲可以去数数门口的树上有几片叶子