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
TypeThe nullable type.
typeConverterFactory
TypeConverterCacheThe 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
stringThe string to convert to an object.
row
IReaderRowThe IReaderRow for the current record.
memberMapData
MemberMapDataThe 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
objectThe object to convert to a string.
row
IWriterRowmemberMapData
MemberMapData
Returns
- string
The string representation of the object.