Read a CSV string into a list of objects.
Public properties are mapped by name, they are case sensitive.
It will automatically map all primitive types such as int, long, string and complex types of GUID, Enum, DateTime.
Properties that do not exist are ignored.
Syntax
Public Function CsvStringToObjectList(Of As {Class, New})( _
ByVal As String _
) As List(Of T)
Dim instance As CsvReader
Dim csvString As String
Dim value As List(Of T)
value = instance.CsvStringToObjectList(Of T)(csvString)
public List<T> CsvStringToObjectList<>(
string
)
where T: class, new()
public:
List<T^>^ CsvStringToObjectListgeneric<typename >
(
String^
)
where T: ref class, gcnew()
Parameters
- csvString
Type Parameters
- T
Example
//Example Mapping Class
public class TestMapper
{
public string Name { get; set; }
public string Birthdate { get; set; }
}
CsvReader csvReader = new CsvReader(); //Trial Mode
//CsvReader csvReader = new CsvReader("place user name here", "place license key here"); //License Mode
//Parameters
string csvString = "Name,Birthdate\r\nJohn,5/30/2013";
List<TestMapper> results = csvReader.CsvStringToObjectList<TestMapper>(csvString);
Console.WriteLine(results[0].Name);
'Example Mapping Class
Public Class TestMapper
Public Property Name() As String
Public Property Birthdate() As String
End Class
Dim csvReader As New CsvReader() 'Trial Mode
'Dim csvReader As New CsvReader("place user name here", "place license key here") 'License Mode
'Parameters
Dim csvString As String = "Name,Birthdate" & vbCrLf & "John,5/30/2013"
Dim results As List(Of TestMapper) = csvReader.CsvStringToObjectList(Of TestMapper)(csvString)
Console.WriteLine(results(0).Name)
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
See Also