Skip to content

Utf8JsonWriter.WriteNumberValue Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll

Overloads

Method Description
WriteNumberValue(decimal) Writes the Decimal value (as a JSON number) as an element of a JSON array.
WriteNumberValue(double) Writes the Double value (as a JSON number) as an element of a JSON array.
WriteNumberValue(float) Writes the Single value (as a JSON number) as an element of a JSON array.
WriteNumberValue(int) Writes the Int32 value (as a JSON number) as an element of a JSON array.
WriteNumberValue(long) Writes the Int64 value (as a JSON number) as an element of a JSON array.
WriteNumberValue(uint) Writes the UInt32 value (as a JSON number) as an element of a JSON array.
WriteNumberValue(ulong) Writes the UInt64 value (as a JSON number) as an element of a JSON array.

WriteNumberValue(decimal)

Source: Utf8JsonWriter.WriteValues.Decimal.cs

Writes the Decimal value (as a JSON number) as an element of a JSON array.

public void WriteNumberValue(decimal value)

Parameters

Name Type Description
value decimal The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the Decimal using the default StandardFormat (that is, 'G').

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

WriteNumberValue(double)

Source: Utf8JsonWriter.WriteValues.Double.cs

Writes the Double value (as a JSON number) as an element of a JSON array.

public void WriteNumberValue(double value)

Parameters

Name Type Description
value double The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the Double using the default StandardFormat on .NET Core 3 or higher and 'G17' on any other framework.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

WriteNumberValue(float)

Source: Utf8JsonWriter.WriteValues.Float.cs

Writes the Single value (as a JSON number) as an element of a JSON array.

public void WriteNumberValue(float value)

Parameters

Name Type Description
value float The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the Single using the default StandardFormat on .NET Core 3 or higher and 'G9' on any other framework.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

WriteNumberValue(int)

Source: Utf8JsonWriter.WriteValues.SignedNumber.cs

Writes the Int32 value (as a JSON number) as an element of a JSON array.

public void WriteNumberValue(int value)

Parameters

Name Type Description
value int The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the Int32 using the default StandardFormat (that is, 'G'), for example: 32767.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

WriteNumberValue(long)

Source: Utf8JsonWriter.WriteValues.SignedNumber.cs

Writes the Int64 value (as a JSON number) as an element of a JSON array.

public void WriteNumberValue(long value)

Parameters

Name Type Description
value long The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the Int64 using the default StandardFormat (that is, 'G'), for example: 32767.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

WriteNumberValue(uint)

Source: Utf8JsonWriter.WriteValues.UnsignedNumber.cs

Writes the UInt32 value (as a JSON number) as an element of a JSON array.

public void WriteNumberValue(uint value)

Parameters

Name Type Description
value uint The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the UInt32 using the default StandardFormat (that is, 'G'), for example: 32767.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

WriteNumberValue(ulong)

Source: Utf8JsonWriter.WriteValues.UnsignedNumber.cs

Writes the UInt64 value (as a JSON number) as an element of a JSON array.

public void WriteNumberValue(ulong value)

Parameters

Name Type Description
value ulong The value to write.

Exceptions

Exception Description
InvalidOperationException Thrown if this would result in invalid JSON being written (while validation is enabled).

Remarks

Writes the UInt64 using the default StandardFormat (that is, 'G'), for example: 32767.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue