c# - if statement...if not this id, try the again later -
i have 2 list of ids, both list have same amount of items, have same ids, not in order, example:
list 1 - (194, 195, 196, 197, 198, 199, 200) list 2 - (194, 200, 198, 195, 197, 196, 199)
i have if statement compairs these ids:
if (cells[i].scheduletaskid == taskid)
this works first id because match (194) other ids not match, there away can if taskid not match cells[i].scheduletaskid seek task id later??
here additional code:
int taskid = reader.getint32(0); (gets taskid database) list<cellmodel> cells
and cellmodel:
public class cellmodel { public uint scheduletaskid { get; set; } public string task { get; set; } public string baselinedate { get; set; } public string scheduleddate { get; set; } public string actualdate { get; set; } public string finisheddate { get; set; } public bool selected { get; set; } public override string tostring() { homecoming scheduletaskid.tostring(); } }
you can utilize linq on collection see if value matches of values contained in collection this:
list<int> list1 = new list<int> { 194, 195, 196, 197, 198, 199, 200 }; //populate db list<cellmodel> cells; if(list1.any(id => id.equals(cells[i].scheduletaskid)))
if have huge list of id's in database , don't want pull downwards whole list compare, loop reader.
while(reader.read) { int taskid = reader.getint32(0); if (cells[i].scheduletaskid == taskid) { // take action , end reading break; } }
c# asp.net if-statement
No comments:
Post a Comment