c# - Retrieve comma-separated values from IQueryable and add to list -
iqueryable<string> scannedbarcodes = xyzdb.tblscannedbarcodes .where(i => i.pullno == lblpullno.text) .select(i => i.barcode);
the result view shows
"678765,090909,243454,675434"
now want add comma-separated values list.
rest of code below:
foreach (var item in scannedbarcodes) { list<string> _barcodes = new list<string>(); _barcodes.add(item); }
how split it?
thanks in advance
the splitting can done using linq follows.
var _barcodes = scannedbarcodes.selectmany(istring => istring.split(new char[]{ ','})) .tolist();
Comments
Post a Comment