TypeConverterExtensionToListConverterTItem Method

Creates a new ListT converter instance.

Definition

Namespace: FolkerKinzel.CsvTools.Mappings
Assembly: FolkerKinzel.CsvTools.Mappings (in FolkerKinzel.CsvTools.Mappings.dll) Version: 1.1.0+1263e8243dc2cd78095f678f813d7d9c52ea4315
C#
public static TypeConverter<List<TItem>?> ToListConverter<TItem>(
	this TypeConverter<TItem> itemsConverter,
	string separator,
	bool nullable = true
)

Parameters

itemsConverter  TypeConverterTItem
A TypeConverterT instance that converts the items.
separator  String
A String that separates the items in a field of the CSV file. When parsing the CSV, separator will not be part of the results.
nullable  Boolean  (Optional)
true to set DefaultValue to null; false to have an empty ListT as DefaultValue.

Type Parameters

TItem
The Type of the items of the ListT objects that the newly created converter can convert.

Return Value

TypeConverterListTItem
A new TypeConverterT instance that converts ListT. The value of its Throwing property is derived from itemsConverter.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type TypeConverterTItem. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

The converter the method creates uses a simple string split and join operation. For nested CSV better use a simple StringConverter and initialize a separate CsvReader, CsvWriter, and CsvMapping to handle the nested items.

Exceptions

ArgumentNullExceptionitemsConverter or separator is null.
ArgumentExceptionseparator is an Empty.

See Also