/// <summary> /// Convert CSV formatted string into an enumerable array of data models. /// </summary> /// <typeparam name="T">Type of class objects to write into.</typeparam> /// <param name="csvString">A multi-line CSV string. Must have at least 2 rows and 2 columns.</param> /// <returns> /// An enumerable list of class objects. /// </returns> /// <remarks> /// • The column headings in the CSV stream must be of the same names as the model property name. Mismatched names are ignored. /// • The CSV column order is not important. /// • Does not perform any language translation. /// • CSV values that cannot be converted to the model column type will default to the default value for that data type.. /// • <see cref="https://github.com/ChuckHill2/CsvExcelExportImport"/> for a mor comprehensive conversion. /// </remarks> public static IEnumerable <T> CsvToModels <T>(this string csvString) { using (var sr = new StringReader(csvString)) { foreach (T v in sr.CsvToModels <T>()) { yield return(v); } } yield break; }