What about the answer that some LINQ uses:
var results = from str in File.ReadAllLines(path).Skip(1) where !String.IsNullOrEmpty(str) let data = str.Split('|') where data.Length == 2 select new Person { Age = Int32.Parse(data[0], NumberStyles.Integer, CultureInfo.CurrentCulture), Name = data[1] };
results now an IEnumerable<Person> , which you can do ToList or ToArray to get a List<Person> or Person[] , or you can just use the results with a foreach .
UPDATE:, here is the Person class needed to make it more functional.
public class Person { public int Age { get; set; } public string Name { get; set; } }
source share