Björn Kreye

Björn Kreye

  • NA
  • 7
  • 623

How to change Headline in Linq

Sep 8 2018 4:57 AM
  1. var lines = File.ReadLines(readFolderFile, Encoding.Default)   
  2.    .Select((line, index) => new { Line = line.Trim(';'), LineNumber = index + 1 })  
  3.    .Where(x => !String.IsNullOrWhiteSpace(x.Line))  
  4.    .Select(x => $"{x.LineNumber};{x.Line};");  
Hi Guys the code above I use to read files and then put them as strings into a IEnumerable.
I just have the problem that all first rows should be HeadLines but in my LineNumber column im getting 1 as the name is there a way to change that and write "RowNumber" instead?  

Answers (3)