private static List <HiscoreSingleRecord> ParseDataIntoList(string csvString) { // Split it by each newline, then for each row create a new HiscoreSingleRecord object into a list which is returned return(csvString.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries) .Select(row => HiscoreSingleRecord.FromString(row)) .ToList()); }
public static HiscoreSingleRecord FromString(string row) { // This takes in a CSV row and fills in the 3 properties - Rank, Value, and sometimes Extra (currently only populated // by the skill experience field) HiscoreSingleRecord result = new HiscoreSingleRecord(); var cols = row.Split(','); // Extra sanity check if (cols.Length < 2) { //System.Diagnostics.Debugger.Break(); throw new Exception("(FromString) Cannot create HiscoreSingleRecord from row - not enough parameters"); } result.Rank = Convert.ToInt64(cols[0]); result.Value = Convert.ToInt64(cols[1]); // If there's a 3rd row if (cols.Length > 2) { result.Extra = Convert.ToInt64(cols[2]); } return(result); }