Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I add "Trim" to this C# statement?

Tags:

arrays

string

c#

I'm stuck. Where can I add "Trim" to this C# statement? Each line will be a separate file name. But because each file may have space after it, I'd like to trim it off.

string[] lines = (File.ReadAllLines(@"C:\Users\Jim\Desktop\adminkeys.cfg"));

Thanks

like image 430
JimDel Avatar asked Nov 30 '12 19:11

JimDel


1 Answers

If you are trying to trim each line, then you need to do it line by line, for example, with LINQ:

string[] lines = (File.ReadAllLines(@"C:\Users\Jim\Desktop\adminkeys.cfg"))
    .Select(l => l.Trim()).ToArray();
like image 179
mellamokb Avatar answered Sep 24 '22 14:09

mellamokb