c# - Distinct items in List -
i have excel spreadsheet trying populate list unique values. have found linqtoexcel prefer not use. @ there 2000 rows isn't much.
my thought was:
list<string> lst = new list<string>(); string item; (i=2; i<2001; i++) { item = ws.cells[i,3]; if(lst.**notinlist**(item)) { lst.add(item); } }
i know there isn't notinlist()
, hoping similar or idea.
use contains instead
list<string> lst = new list<string>(); string item; (i=2; i<2001; i++) { item = ws.cells[i,3]; if(!lst.contains(item)) { lst.add(item); } }
Comments
Post a Comment