c# - How do I compare data in a List to Data in a DataView? -
i have dataview
containing data, need compare dataview list<string>
, data list<string>
not in dataview
. list populated using listbox
.
here list:
//populate list<string> listbox private void loadlist() { var vehicle = new list<string>(); var model = new list<string>(); foreach (listitem automobile in listbox1.items) { var components = automobile.value.split('\\'); vehicle.add(components.first()); model.add(components.last()); } (var = 0; < vehicle.count; i++) { // compare items in list<string> dataview // data list not in dataview } }
this listbox
, list<string>
before , after.
the dataview data structure:
the vehicle
, model
both primary key
(composite).
*this dataview member:
private static dataview localdataview { get; set; }
how compare list against dataview , vehicle , model list not exists in dataview?
you can use except
list.except(localdataview.select(x => string.form("{0} {1}" , x.vehicle, x.model).tolist());