Class BoxedValue<T>
Represents a typed representation of the boxed value type.
Inherited Members
Namespace: DotNext .Runtime
Assembly: DotNext.dll
Syntax
public abstract class BoxedValue<T> where T : struct
Type Parameters
Name | Description |
---|---|
T | The value type. |
Remarks
Equals(object), Get
static int Unbox(object obj) => (int)obj;
BoxedValue<int> boxed = BoxedValue<int>.Box(42);
int value = Unbox(boxed);
Additionally, it means that GetT
type,
not for Boxed
Methods
| Edit this page View SourceBox(T)
Converts a value type to an object reference.
Declaration
public static BoxedValue<T> Box(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be boxed. |
Returns
Type | Description |
---|---|
Boxed |
A boxed representation of the value. |
Equals(object?)
Determines whether the specified object is equal to the current object.
Declaration
public override abstract bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
| Edit this page View SourceGetHashCode()
Serves as the default hash function.
Declaration
public override abstract int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for the current object. |
Overrides
| Edit this page View SourceGetTypedReference(object?)
Converts untyped reference to a boxed value into a typed reference.
Declaration
public static BoxedValue<T>? GetTypedReference(object? boxedValue)
Parameters
Type | Name | Description |
---|---|---|
object | boxedValue | The boxed value of type |
Returns
Type | Description |
---|---|
Boxed |
The typed reference to a boxed value of type |
Remarks
This method doesn't allocate memory.
Exceptions
Type | Condition |
---|---|
Argument |
|
ToString()
Returns a string that represents the current object.
Declaration
public override abstract string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |
Overrides
| Edit this page View SourceTryBox(in T?)
Boxes nullable value type to an object.
Declaration
public static BoxedValue<T>? TryBox(in T? value)
Parameters
Type | Name | Description |
---|---|---|
T? | value | The value to be boxed. |
Returns
Type | Description |
---|---|
Boxed |
A boxed representation of the value. |
Operators
| Edit this page View Sourceexplicit operator BoxedValue<T>?(in T?)
Boxes nullable value type to an object.
Declaration
public static explicit operator BoxedValue<T>?(in T? value)
Parameters
Type | Name | Description |
---|---|---|
T? | value | The value to be boxed. |
Returns
Type | Description |
---|---|
Boxed |
A boxed representation of the value. |
explicit operator BoxedValue<T>(T)
Converts a value type to an object reference.
Declaration
public static explicit operator BoxedValue<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to be boxed. |
Returns
Type | Description |
---|---|
Boxed |
A boxed representation of the value. |
implicit operator ValueReference<T>(BoxedValue<T>)
Obtains a reference to the boxed value.
Declaration
public static implicit operator ValueReference<T>(BoxedValue<T> boxedValue)
Parameters
Type | Name | Description |
---|---|---|
Boxed |
boxedValue | Boxed value. |
Returns
Type | Description |
---|---|
Value |
Mutable reference to the boxed value. |
implicit operator ValueType?(BoxedValue<T>?)
Converts a typed reference to a boxed value to untyped reference.
Declaration
public static implicit operator ValueType?(BoxedValue<T>? boxedValue)
Parameters
Type | Name | Description |
---|---|---|
Boxed |
boxedValue | The boxed value. |
Returns
Type | Description |
---|---|
Value |
Untyped reference to a boxed value. |
implicit operator T(BoxedValue<T>)
Unboxes the value.
Declaration
public static implicit operator T(BoxedValue<T> boxedValue)
Parameters
Type | Name | Description |
---|---|---|
Boxed |
boxedValue | The boxed representation of the value. |
Returns
Type | Description |
---|---|
T |