Table of Contents

Class NullableConverter

Namespace
CsvHelper.TypeConversion
Assembly
CsvHelper.dll

Converts a Nullable<T> to and from a string.

public class NullableConverter : DefaultTypeConverter, ITypeConverter
Inheritance
NullableConverter
Implements
Inherited Members

Constructors

NullableConverter(Type, TypeConverterCache)

Creates a new NullableConverter for the given Nullable<T> Type.

public NullableConverter(Type type, TypeConverterCache typeConverterFactory)

Parameters

type Type

The nullable type.

typeConverterFactory TypeConverterCache

The type converter factory.

Exceptions

ArgumentException

type is not a nullable type.

Properties

NullableType

Gets the type of the nullable.

public Type NullableType { get; }

Property Value

Type

The type of the nullable.

UnderlyingType

Gets the underlying type of the nullable.

public Type? UnderlyingType { get; }

Property Value

Type

The underlying type.

UnderlyingTypeConverter

Gets the type converter for the underlying type.

public ITypeConverter UnderlyingTypeConverter { get; }

Property Value

ITypeConverter

The type converter.

Methods

ConvertFromString(string?, IReaderRow, MemberMapData)

Converts the string to an object.

public override object? ConvertFromString(string? text, IReaderRow row, MemberMapData memberMapData)

Parameters

text string

The string to convert to an object.

row IReaderRow

The IReaderRow for the current record.

memberMapData MemberMapData

The MemberMapData for the member being created.

Returns

object

The object created from the string.

ConvertToString(object?, IWriterRow, MemberMapData)

Converts the object to a string.

public override string? ConvertToString(object? value, IWriterRow row, MemberMapData memberMapData)

Parameters

value object

The object to convert to a string.

row IWriterRow
memberMapData MemberMapData

Returns

string

The string representation of the object.