Note
In the following code examples - for easier readability - exception
handling has been omitted.
public DoubleConverter(
IFormatProvider? formatProvider = null,
string? format = "G17",
NumberStyles styles = NumberStyles.Any,
bool throwing = true,
double defaultValue = 0
)
Public Sub New (
Optional formatProvider As IFormatProvider = Nothing,
Optional format As String = "G17",
Optional styles As NumberStyles = NumberStyles.Any,
Optional throwing As Boolean = true,
Optional defaultValue As Double = 0
)
public:
DoubleConverter(
IFormatProvider^ formatProvider = nullptr,
String^ format = L"G17",
NumberStyles styles = NumberStyles::Any,
bool throwing = true,
double defaultValue = 0
)
new :
?formatProvider : IFormatProvider *
?format : string *
?styles : NumberStyles *
?throwing : bool *
?defaultValue : float
(* Defaults:
let _formatProvider = defaultArg formatProvider null
let _format = defaultArg format "G17"
let _styles = defaultArg styles NumberStyles.Any
let _throwing = defaultArg throwing true
let _defaultValue = defaultArg defaultValue 0
*)
-> DoubleConverter
Object serialization with CSV:
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;
});
}
}
ArgumentException | format is "D", "d", "X", or "x". |