Variantclass

A Variant is a type that can hold any value, and also keeps track of the type of the value it holds. It's useful for cases where you want to store a value of an unknown type, or when you want to serialize/deserialize values of various types in a generic way.

objectVariant
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed struct Sandbox.Variant

Constructors1

Showing 1 constructors

public Variant(object o, System.Type t = null)PUBLICCONSTRUCTOR

ParameterTypeDescription
oobject
t = nullType

Methods3

Showing 3 methods

public T Get()PUBLIC

Returns:T

public static override object JsonRead(System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert)PUBLICSTATICOVERRIDE

ParameterTypeDescription
readerUtf8JsonReader
typeToConvertType
Returns:object

public static override void JsonWrite(object value, System.Text.Json.Utf8JsonWriter writer)PUBLICSTATICOVERRIDE

ParameterTypeDescription
valueobject
writerUtf8JsonWriter
Returns:void

Properties2

Showing 2 properties

public System.Type Sandbox.Variant.Type { get; set; }PUBLICGETSET

The type of the value currently stored in the Variant. This is automatically set when you assign a value to the Variant.

Returns:Type

public object Sandbox.Variant.Value { get; set; }PUBLICGETSET

Gets or sets the value associated with this instance.

Returns:object

On this page