c# - Verify the Sequential Increment of a Property Common to Two Lists -
i have following two lists.
first list:
list 1[0] {id=11111,date='01/01/2013',processid='100'} list 1[1] {id=11111,date='01/01/2013',processid='101'}
second list:
list 2[0] {id=11111,date='01/01/2013',processid='102'} list 2[1] {id=11111,date='01/01/2013',processid='103'}
i need check second list 'list 2' should start next number processid.
i'm not sure how composed lists, , if lists of anonymous object, assuming constructed this:
var list1 = enumerable.range(100, 3).select(i => new { id=1111, date="01/01/2013", processid= }).tolist(); var list2 = enumerable.range(103, 3).select(i => new { id=1111, date="01/01/2013", processid= }).tolist(); then can verify processid of list2 next in sequence this:
bool list2startswithnextprocessid = list2.min(o => o.processid) == list1.max(o => o.processid) + 1; or more verbosely:
int list1ender = list1.max(o => o.processid); int list2starter = list2.min(o => o.processid); console.writeline ("list1 endswith {0}. list2 startswith {1}, {2} next in sequence.", list1ender, list2starter, list2starter == list1ender + 1 ? "" : "not");
Comments
Post a Comment