c# - How do I output the results of a LINQ command to a text file? -
var arrresults = array1.join(array2, x => x.id, x => x.id, (first, second) => new { idrecord = first.id, count1 = first.count, count2 = second.count, }) .orderby(item => item.idrecord).toarray(); // bind & display results in datagrid datagridview1.datasource = arrresults;
my above code want to, , shows results in datagrid control. now, i'd export results text file, c:\output.txt, instead. how do this?
my previous attempts involve getting errors "cannot convert 'string' system.collections.generic.ienumerable".
first convert results strings:
var lines = arrresults.select(record => record.id + " " + record.count1 + " " + record.count2);//todo fix formatting
then write them file.
file.writealllines("file.txt", lines);
Comments
Post a Comment