According to this , we have a List<string> in .NET 2.0.
So try with List<string> .
String []lines = System.IO.File.ReadAllLines(path); List<string> yourLinesTrimed = new List<string>; foreach (String line in lines) { yourLinesTrimed.Add(line.Trim()); }
You can then convert the List<string> to an array using ToArray() .
Create a method that does this:
public String[] TrimAnArray(String[] lines) { List<string> yourLinesTrimed = new List<string>; foreach (String line in lines) { yourLinesTrimed.Add(line.Trim()); } return yourLinesTrimed.ToArray(); }
source share