Class TomlPrimitiveValue
Represents a TOML primitive value (string, integer, float, boolean, or datetime).
public class TomlPrimitiveValue : TomlValue, IEnumerable<TomlToken>, IEnumerable, IEquatable<TomlPrimitiveValue>
- Inheritance
-
TomlPrimitiveValue
- Implements
- Inherited Members
Examples
// Create primitive values
var stringValue = new TomlPrimitiveValue("hello");
var intValue = new TomlPrimitiveValue(42);
var boolValue = new TomlPrimitiveValue(true);
// Use implicit casts for convenient access
string str = (string?)stringValue ?? "default";
int num = ((int?)intValue) ?? 0;
Remarks
TomlPrimitiveValue is the container for all simple TOML value types. It provides implicit cast operators to common .NET types for convenient conversion (string, int, long, bool, DateTime, double, decimal, etc.).
Constructors
TomlPrimitiveValue(bool)
Initializes a new instance of the TomlPrimitiveValue class with a boolean value.
public TomlPrimitiveValue(bool value)
Parameters
valueboolThe boolean value.
TomlPrimitiveValue(byte)
Initializes a new instance of the TomlPrimitiveValue class with an 8-bit unsigned integer value.
public TomlPrimitiveValue(byte value)
Parameters
valuebyteThe byte value.
TomlPrimitiveValue(DateTime)
Initializes a new instance of the TomlPrimitiveValue class with a datetime value.
public TomlPrimitiveValue(DateTime value)
Parameters
valueDateTimeThe datetime value (stored as offset datetime).
TomlPrimitiveValue(decimal)
Initializes a new instance of the TomlPrimitiveValue class with a decimal value.
public TomlPrimitiveValue(decimal value)
Parameters
valuedecimalThe decimal value.
TomlPrimitiveValue(double)
Initializes a new instance of the TomlPrimitiveValue class with a double-precision floating-point value.
public TomlPrimitiveValue(double value)
Parameters
valuedoubleThe double value.
TomlPrimitiveValue(Guid)
Initializes a new instance of the TomlPrimitiveValue class with a GUID value.
public TomlPrimitiveValue(Guid value)
Parameters
valueGuidThe GUID value (stored as a string).
TomlPrimitiveValue(short)
Initializes a new instance of the TomlPrimitiveValue class with a 16-bit integer value.
public TomlPrimitiveValue(short value)
Parameters
valueshortThe short integer value.
TomlPrimitiveValue(int)
Initializes a new instance of the TomlPrimitiveValue class with a 32-bit integer value.
public TomlPrimitiveValue(int value)
Parameters
valueintThe integer value.
TomlPrimitiveValue(long)
Initializes a new instance of the TomlPrimitiveValue class with a 64-bit integer value.
public TomlPrimitiveValue(long value)
Parameters
valuelongThe long integer value.
TomlPrimitiveValue(sbyte)
Initializes a new instance of the TomlPrimitiveValue class with an 8-bit signed integer value.
public TomlPrimitiveValue(sbyte value)
Parameters
valuesbyteThe signed byte value.
TomlPrimitiveValue(float)
Initializes a new instance of the TomlPrimitiveValue class with a single-precision floating-point value.
public TomlPrimitiveValue(float value)
Parameters
valuefloatThe float value.
TomlPrimitiveValue(string)
Initializes a new instance of the TomlPrimitiveValue class with a string value.
public TomlPrimitiveValue(string value)
Parameters
valuestringThe string value.
TomlPrimitiveValue(string, TomlValueType)
Initializes a new instance of the TomlPrimitiveValue class with a string value and explicit type.
public TomlPrimitiveValue(string value, TomlValueType type)
Parameters
valuestringThe string value representation.
typeTomlValueTypeThe TOML value type.
Fields
BIN_NUMBER_PREFIX
Prefix for binary number literals (e.g., 0b1101).
public const string BIN_NUMBER_PREFIX = "0b"
Field Value
FALSE_VALUE_LITERAL
TOML literal for the boolean value false.
public const string FALSE_VALUE_LITERAL = "false"
Field Value
OCT_NUMBER_PREFIX
Prefix for octal number literals (e.g., 0o17).
public const string OCT_NUMBER_PREFIX = "0o"
Field Value
SPECIAL_FLOAT_INF_LITERAL
TOML special float literal representing positive or negative infinity (inf).
public const string SPECIAL_FLOAT_INF_LITERAL = "inf"
Field Value
SPECIAL_FLOAT_MINUS_INF_LITERAL
TOML special float literal representing negative infinity (-inf).
public const string SPECIAL_FLOAT_MINUS_INF_LITERAL = "-inf"
Field Value
SPECIAL_FLOAT_NAN_LITERAL
TOML special float literal representing Not-a-Number (nan).
public const string SPECIAL_FLOAT_NAN_LITERAL = "nan"
Field Value
SPECIAL_FLOAT_PLUS_INF_LITERAL
TOML special float literal representing positive infinity (+inf).
public const string SPECIAL_FLOAT_PLUS_INF_LITERAL = "+inf"
Field Value
TRUE_VALUE_LITERAL
TOML literal for the boolean value true.
public const string TRUE_VALUE_LITERAL = "true"
Field Value
Properties
Type
Gets the TOML type of the Value.
public TomlValueType Type { get; }
Property Value
Value
Gets raw (string) value.
public string Value { get; }
Property Value
Methods
Equals(TomlPrimitiveValue?)
public bool Equals(TomlPrimitiveValue? other)
Parameters
otherTomlPrimitiveValue
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToString()
public override string ToString()