Example #1
0
        public string Contain_Csv(LastNewLine lastNewLine, bool header)
        {
            var persons = new[]
            {
                new Person("Alice", 27),
                new Person("Bob", 26)
            };

            using var csvStream = CsvStream
                                  .Of(persons, Configuration(header), lastNewLine)
                                  .Build();
            using var reader = new StreamReader(csvStream, Encoding.UTF8);

            var csv = reader.ReadToEnd();

            return(csv);
        }
Example #2
0
        public async Task <string> Contain_Csv_Async(LastNewLine lastNewLine, bool header)
        {
            var persons = new[]
            {
                new Person("Charlie", 9),
                new Person("Daisy", 7)
            };

#if !NET472
            await
#endif
            using var csvStream = CsvStream
                                  .Of(persons.ToAsyncEnumerable(), Configuration(header), lastNewLine)
                                  .Build();
            using var reader = new StreamReader(csvStream, Encoding.UTF8);

            var csv = await reader.ReadToEndAsync();

            return(csv);
        }