Type:Nullable`1: Difference between revisions

From Resonite Wiki
m chore: type:value -> value types
cleanup
 
Line 1: Line 1:
A Nullable<T> is a [[Generic Type|generic]] [[Value Type | value]] type that can store a null value - normally only possible by [[Reference Type | reference types]].
The '''Nullable&lt;T&gt;''' type is a C# construct that wraps around a non-nullable [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types C# value type] to allow the type to store an additional value--<code>null</code>--representing the absense of a value.


For more information on how this type functions, see the [https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 Microsoft documentation on Nullable<T>]
Nullable types are a [[value type]] in the FrooxEngine data model, but an [[Type:Object|Object]] in the ProtoFlux data model.


== Usage ==
Nullable types are useful when one is unsure whether a value may or may not exist in the first place, rather than reling on some sort of default value that represents the absense of a value. In addition, whenever an "unset" state is useful to keep track of, nullables can come in handy.
Use this wherever you need a value variable (for example [[Type:Bool | bool]] or [[Type:Float | float]]), but you also need to track an unset/empty/null state.


== See Also ==
== See Also ==
* Microsoft's documentation on the [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types nullable value types] & [https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references nullable reference types].
* Wikipedia's definition of [https://en.wikipedia.org/wiki/Nullable_type nullable types].
* Wikipedia's definition of [https://en.wikipedia.org/wiki/Nullable_type nullable types].
* Microsoft's documentation on the [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-value-types nullable value types] & [https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references nullable reference types].


[[Category:Type]]
[[Category:Type]]
[[Category:Value Types]]
[[Category:Value Types]]

Latest revision as of 02:58, 10 December 2024

The Nullable<T> type is a C# construct that wraps around a non-nullable C# value type to allow the type to store an additional value--null--representing the absense of a value.

Nullable types are a value type in the FrooxEngine data model, but an Object in the ProtoFlux data model.

Nullable types are useful when one is unsure whether a value may or may not exist in the first place, rather than reling on some sort of default value that represents the absense of a value. In addition, whenever an "unset" state is useful to keep track of, nullables can come in handy.

See Also