CsvWriter(TextWriter, IEnumerableString, Boolean, Char) Constructor

Initializes a new CsvWriter object with the column names for the header row to be written.

Definition

Namespace: FolkerKinzel.CsvTools
Assembly: FolkerKinzel.CsvTools (in FolkerKinzel.CsvTools.dll) Version: 2.0.1+2345335399184346d9b2cc992ed5c814406052c1
C#
public CsvWriter(
	TextWriter writer,
	IEnumerable<string?> columnNames,
	bool caseSensitive = false,
	char delimiter = ','
)

Parameters

writer  TextWriter
The TextWriter used for writing.
columnNames  IEnumerableString

A collection of column names for the header to be written.

The collection determines the order in which the columns appear in the CSV and their index in CsvRecord. The CsvRecord instance, which the Record property of the newly initialized CsvWriter gets, can be accessed with this column names.

caseSensitive  Boolean  (Optional)
If true, column names that differ only in upper and lower case are also accepted, otherwise false.
delimiter  Char  (Optional)
The field separator character.

Exceptions

ArgumentNullExceptionwriter or columnNames is null.
ArgumentExceptionA column name in columnNames occurs twice. With caseSensitive can be chosen whether the comparison is case-sensitive or not.
ArgumentOutOfRangeExceptiondelimiter is either the double quotes " or a line break character ('\r' or '\n').

See Also