CharConverter Constructor

TypeConverterT implementation for Char.

Definition

Namespace: FolkerKinzel.CsvTools.Mappings.TypeConverters
Assembly: FolkerKinzel.CsvTools.Mappings (in FolkerKinzel.CsvTools.Mappings.dll) Version: 1.1.0+1263e8243dc2cd78095f678f813d7d9c52ea4315
C#
public CharConverter(
	bool throwing = true,
	char defaultValue = '\x0000'
)

Parameters

throwing  Boolean  (Optional)
Sets the value of the Throwing property.
defaultValue  Char  (Optional)
Sets the value of the DefaultValue property.

Example

  Note

In the following code examples - for easier readability - exception handling has been omitted.

Object serialization with CSV:

C#
using FolkerKinzel.CsvTools;
using FolkerKinzel.CsvTools.Mappings;
using FolkerKinzel.CsvTools.Mappings.TypeConverters;

namespace Benchmarks;

internal static partial class CalculationWriter
{
    internal static string WriteDefault(Calculation[] data)
    {
        var doubleConverter = new DoubleConverter();

        CsvMapping mapping = CsvMappingBuilder
            .Create()
            .AddProperty("First", doubleConverter)
            .AddProperty("Operator", new CharConverter())
            .AddProperty("Second", doubleConverter)
            .AddProperty("Result", doubleConverter)
            .Build();

        return data.ToCsv(
            mapping, 
            static (calculation, mapping) =>
                   {
                       mapping.First = calculation.First;
                       mapping.Operator = calculation.Operator;
                       mapping.Second = calculation.Second;
                       mapping.Result = calculation.Result;
                   });
    }
}

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

See Also