public void TestReaderGetField() { using (var stream = new MemoryStream()) using (var writer = new StreamWriter(stream)) using (var reader = new StreamReader(stream)) using (var dtReader = new DelimitedTextReader(reader)) { writer.Write("Field1,Field2,Field3,Field4,Field5\r\n"); writer.Write("value1,100,true,\"12/31/2016\", 25.76\r\n"); writer.Flush(); stream.Position = 0; dtReader.FirstRowIsHeader = true; dtReader.Read(); Assert.Equal("value1", dtReader.GetField <string>(0)); Assert.Equal(100, dtReader.GetField <int>(1)); Assert.True(dtReader.GetField <bool>(2)); Assert.Equal(DateTime.Parse("12/31/2016").ToShortDateString(), dtReader.GetField <DateTime>(3).ToShortDateString()); Assert.Equal(25.76M, dtReader.GetField <decimal>(4)); } }