TomlFormatHelper Class

Helper methods to format values into TOML-compliant strings.

public static class TomlFormatHelper

Methods

NameDescription
ToString(TomlDateTime)Converts a TomlDateTime to its TOML representation.
ToString(bool)Converts a boolean to its TOML representation.
ToString(byte, TomlPropertyDisplayKind)Converts an 8-bit unsigned integer to its TOML representation.
ToString(DateOnly, TomlPropertyDisplayKind)Converts a DateOnly to its TOML representation.
ToString(DateTime, TomlPropertyDisplayKind)Converts a DateTime to its TOML representation.
ToString(DateTimeOffset, TomlPropertyDisplayKind)Converts a DateTimeOffset to its TOML representation.
ToString(double)Converts a double-precision floating point value to its TOML representation.
ToString(short, TomlPropertyDisplayKind)Converts a 16-bit signed integer to its TOML representation.
ToString(int, TomlPropertyDisplayKind)Converts a 32-bit integer to its TOML representation.
ToString(long, TomlPropertyDisplayKind)Converts a 64-bit integer to its TOML representation.
ToString(sbyte, TomlPropertyDisplayKind)Converts an 8-bit signed integer to its TOML representation.
ToString(float)Converts a single-precision floating point value to its TOML representation.
ToString(string, TomlPropertyDisplayKind)Converts a string to its TOML representation using the provided display kind.
ToString(TimeOnly, TomlPropertyDisplayKind)Converts a TimeOnly to its TOML representation.
ToString(ushort, TomlPropertyDisplayKind)Converts a 16-bit unsigned integer to its TOML representation.
ToString(uint, TomlPropertyDisplayKind)Converts an unsigned 32-bit integer to its TOML representation.
ToString(ulong, TomlPropertyDisplayKind)Converts an unsigned 64-bit integer to its TOML representation.

ToString overloads

ToString(TomlDateTime)

TomlFormatHelper.cs

Converts a TomlDateTime to its TOML representation.

public static string ToString(TomlDateTime tomlDateTime)
Parameters
tomlDateTime TomlDateTime
The value to format.
Returns

string The TOML string.

ToString(bool)

TomlFormatHelper.cs

Converts a boolean to its TOML representation.

public static string ToString(bool b)
Parameters
b bool
The boolean value.
Returns

string The TOML string.

ToString(byte, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts an 8-bit unsigned integer to its TOML representation.

public static string ToString(byte u8, TomlPropertyDisplayKind displayKind)
Parameters
u8 byte
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(DateOnly, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a DateOnly to its TOML representation.

public static string ToString(DateOnly dateOnly, TomlPropertyDisplayKind displayKind)
Parameters
dateOnly DateOnly
The date value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(DateTime, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a DateTime to its TOML representation.

public static string ToString(DateTime dateTime, TomlPropertyDisplayKind displayKind)
Parameters
dateTime DateTime
The date/time value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

Exceptions
TomlException
A local value near DateTime.MinValue or DateTime.MaxValue is out of range once converted to UTC.

ToString(DateTimeOffset, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a DateTimeOffset to its TOML representation.

public static string ToString(DateTimeOffset dateTimeOffset, TomlPropertyDisplayKind displayKind)
Parameters
dateTimeOffset DateTimeOffset
The date/time value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(double)

TomlFormatHelper.cs

Converts a double-precision floating point value to its TOML representation.

public static string ToString(double value)
Parameters
value double
The double value.
Returns

string The TOML string.

ToString(short, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a 16-bit signed integer to its TOML representation.

public static string ToString(short i16, TomlPropertyDisplayKind displayKind)
Parameters
i16 short
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(int, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a 32-bit integer to its TOML representation.

public static string ToString(int i32, TomlPropertyDisplayKind displayKind)
Parameters
i32 int
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(long, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a 64-bit integer to its TOML representation.

public static string ToString(long i64, TomlPropertyDisplayKind displayKind)
Parameters
i64 long
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(sbyte, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts an 8-bit signed integer to its TOML representation.

public static string ToString(sbyte i8, TomlPropertyDisplayKind displayKind)
Parameters
i8 sbyte
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(float)

TomlFormatHelper.cs

Converts a single-precision floating point value to its TOML representation.

public static string ToString(float value)
Parameters
value float
The float value.
Returns

string The TOML string.

ToString(string, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a string to its TOML representation using the provided display kind.

public static string ToString(string s, TomlPropertyDisplayKind displayKind)
Parameters
s string
The string value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

Exceptions
TomlException
The string contains an unpaired surrogate, which TOML cannot represent.

ToString(TimeOnly, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a TimeOnly to its TOML representation.

public static string ToString(TimeOnly timeOnly, TomlPropertyDisplayKind displayKind)
Parameters
timeOnly TimeOnly
The time value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(ushort, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts a 16-bit unsigned integer to its TOML representation.

public static string ToString(ushort u16, TomlPropertyDisplayKind displayKind)
Parameters
u16 ushort
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(uint, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts an unsigned 32-bit integer to its TOML representation.

public static string ToString(uint u32, TomlPropertyDisplayKind displayKind)
Parameters
u32 uint
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

ToString(ulong, TomlPropertyDisplayKind)

TomlFormatHelper.cs

Converts an unsigned 64-bit integer to its TOML representation.

public static string ToString(ulong u64, TomlPropertyDisplayKind displayKind)
Parameters
u64 ulong
The integer value.
displayKind TomlPropertyDisplayKind
The display kind.
Returns

string The TOML string.

Exceptions
TomlException
The value is greater than Int64.MaxValue, the largest TOML integer.