Show / Hide Table of Contents

Struct ValueReference<T>

Represents a mutable reference to the field.

Implements
IEquatable<ValueReference<T>>
IEqualityOperators<ValueReference<T>, ValueReference<T>, bool>
ISupplier<T>
IFunctional<Func<T>>
IConsumer<T>
IFunctional<Action<T>>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: DotNext.Runtime
Assembly: DotNext.dll
Syntax
public readonly struct ValueReference<T> : IEquatable<ValueReference<T>>, IEqualityOperators<ValueReference<T>, ValueReference<T>, bool>, ISupplier<T>, IFunctional<Func<T>>, IConsumer<T>, IFunctional<Action<T>>
Type Parameters
Name Description
T

The type of the field.

Constructors

| Edit this page View Source

ValueReference(object, ref T)

Represents a mutable reference to the field.

Declaration
public ValueReference(object owner, ref T fieldRef)
Parameters
Type Name Description
object owner

An object that owns the field.

T fieldRef

The reference to the field.

| Edit this page View Source

ValueReference(T)

Creates a reference to the anonymous value.

Declaration
public ValueReference(T value)
Parameters
Type Name Description
T value

The anonymous value.

| Edit this page View Source

ValueReference(ref T)

Creates a reference to a static field.

Declaration
[CLSCompliant(false)]
public ValueReference(ref T staticFieldRef)
Parameters
Type Name Description
T staticFieldRef

A reference to the static field.

Remarks

If T is a value type then your static field MUST be marked with FixedAddressValueTypeAttribute. Otherwise, the behavior is unpredictable. Correctness of this constructor is based on the fact that static fields are stored as elements of object array allocated by the runtime in the Pinned Object Heap. It means that the address of the field cannot be changed by GC.

See Also
Internals of the POH
| Edit this page View Source

ValueReference(T[], int)

Creates a reference to an array element.

Declaration
public ValueReference(T[] array, int index)
Parameters
Type Name Description
T[] array

The array.

int index

The index of the array element.

Exceptions
Type Condition
ArrayTypeMismatchException

T is a reference type, and array is not an array of type T.

Properties

| Edit this page View Source

IsEmpty

Gets a value indicating that is reference is empty.

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
bool
| Edit this page View Source

Value

Gets a reference to the field.

Declaration
public ref T Value { get; }
Property Value
Type Description
T

Methods

| Edit this page View Source

Equals(ValueReference<T>)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(ValueReference<T> reference)
Parameters
Type Name Description
ValueReference<T> reference
Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

| Edit this page View Source

Equals(object?)

Indicates whether this instance and a specified object are equal.

Declaration
public override bool Equals(object? other)
Parameters
Type Name Description
object other
Returns
Type Description
bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Overrides
ValueType.Equals(object)
| Edit this page View Source

GetHashCode()

Returns the hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A 32-bit signed integer that is the hash code for this instance.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

ToString()

Returns the fully qualified type name of this instance.

Declaration
public override string? ToString()
Returns
Type Description
string

The fully qualified type name.

Overrides
ValueType.ToString()

Operators

| Edit this page View Source

operator ==(ValueReference<T>, ValueReference<T>)

Determines whether the two references point to the same field.

Declaration
public static bool operator ==(ValueReference<T> x, ValueReference<T> y)
Parameters
Type Name Description
ValueReference<T> x

The first reference to compare.

ValueReference<T> y

The second reference to compare.

Returns
Type Description
bool

true if both references are equal; otherwise, false.

| Edit this page View Source

explicit operator Action<T>(ValueReference<T>)

Returns a setter for the memory location.

Declaration
public static explicit operator Action<T>(ValueReference<T> reference)
Parameters
Type Name Description
ValueReference<T> reference

A reference to a value.

Returns
Type Description
Action<T>

A setter for the memory location.

| Edit this page View Source

explicit operator Func<T>(ValueReference<T>)

Returns a getter for the memory location.

Declaration
public static explicit operator Func<T>(ValueReference<T> reference)
Parameters
Type Name Description
ValueReference<T> reference

A reference to a value.

Returns
Type Description
Func<T>

A getter for the memory location.

| Edit this page View Source

implicit operator ReadOnlyValueReference<T>(ValueReference<T>)

Converts mutable field reference to immutable field reference.

Declaration
public static implicit operator ReadOnlyValueReference<T>(ValueReference<T> reference)
Parameters
Type Name Description
ValueReference<T> reference

The reference to convert.

Returns
Type Description
ReadOnlyValueReference<T>

The immutable field reference.

| Edit this page View Source

implicit operator Span<T>(ValueReference<T>)

Gets a span over the referenced value.

Declaration
public static implicit operator Span<T>(ValueReference<T> reference)
Parameters
Type Name Description
ValueReference<T> reference

The value reference.

Returns
Type Description
Span<T>

The span that contains Value; or empty span if reference is empty.

| Edit this page View Source

operator !=(ValueReference<T>, ValueReference<T>)

Determines whether the two references point to the different fields.

Declaration
public static bool operator !=(ValueReference<T> x, ValueReference<T> y)
Parameters
Type Name Description
ValueReference<T> x

The first reference to compare.

ValueReference<T> y

The second reference to compare.

Returns
Type Description
bool

true if both references are not equal; otherwise, false.

Implements

IEquatable<T>
IEqualityOperators<TSelf, TOther, TResult>
ISupplier<TResult>
IFunctional<TDelegate>
IConsumer<T>
IFunctional<TDelegate>

Extension Methods

BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
Collection.ToAsyncEnumerator<TEnumerator, T>(TEnumerator, CancellationToken)
Collection.ToClassicEnumerator<TEnumerator, T>(TEnumerator)
Enumerator.Skip<TEnumerator, T>(ref TEnumerator, int)
ExpressionBuilder.Const<T>(T)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾