Table of Contents

Struct NullableRefReadOnly<T>

Namespace
Sdl3Sharp.Utilities
Assembly
Sdl3Sharp.dll

Represents a explicitly nullable read-only reference

public readonly ref struct NullableRefReadOnly<T>

Type Parameters

T

The type of value the NullableRefReadOnly<T> represents a reference of

Inherited Members

Remarks

To construct a NullableRefReadOnly<T> that represents a null-reference, use Null or default(NullableRefReadOnly<T>).

Constructors

NullableRefReadOnly(ref readonly T)

Represents a explicitly nullable read-only reference

public NullableRefReadOnly(ref readonly T target)

Parameters

target T

An actual read-only reference to the value of type T the NullableRefReadOnly<T> should represent a reference to

Remarks

To construct a NullableRefReadOnly<T> that represents a null-reference, use Null or default(NullableRefReadOnly<T>).

Properties

HasTarget

Gets a value indicating whether this NullableRefReadOnly<T> does not represent a null-reference and the Target property can be safely dereferenced

public bool HasTarget { get; }

Property Value

bool

A value indicating whether this NullableRefReadOnly<T> does not represent a null-reference

IsNull

Gets a value indicating whether this NullableRefReadOnly<T> does represent a null-reference

public bool IsNull { get; }

Property Value

bool

A value indicating whether this NullableRefReadOnly<T> does represent a null-reference

Remarks

If the value of this property is true, the Target property can't be safely dereferenced.

Null

Gets a NullableRefReadOnly<T> that represents a null-reference

public static NullableRefReadOnly<T> Null { get; }

Property Value

NullableRefReadOnly<T>

A NullableRefReadOnly<T> that represents a null-reference

Remarks

Do not try the dereference the returned reference from a call to GetReferenceOrNull() on the resulting value of this property!

Target

Gets an actual read-only reference to the value of type T this NullableRefReadOnly<T> references

public ref readonly T Target { get; }

Property Value

T

An actual read-only reference to the value of type T this NullableRefReadOnly<T> references

Remarks

If the value of the HasTarget property is false or the value of the IsNull property is true, accessing this property will throw an InvalidOperationException.

Exceptions

InvalidOperationException

The NullableRefReadOnly<T> represents a null-reference

Methods

Equals(NullableRefReadOnly<T>)

public bool Equals(NullableRefReadOnly<T> other)

Parameters

other NullableRefReadOnly<T>

Returns

bool

Equals(NullableRef<T>)

public bool Equals(NullableRef<T> other)

Parameters

other NullableRef<T>

Returns

bool

Equals(object?)

Calls to this method are not supported

[Obsolete("Calls to this method are not supported. This method will always throw an exception. Use the \"Equals\" methods or the equality operators instead.")]
[DoesNotReturn]
public override bool Equals(object? obj)

Parameters

obj object

Not supported

Returns

bool

Not supported

Exceptions

NotSupportedException

always

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

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

GetReferenceOrNull()

Gets an actual read-only reference to the value of type T this NullableRefReadOnly<T> references, without validating if it's safely dereferencable

public ref readonly T GetReferenceOrNull()

Returns

T

An actual read-only reference to the value of type T this NullableRefReadOnly<T> references

Remarks

This method does not validate if the represented reference is safely dereferencable! Users should check the value of the HasTarget property or the value of the IsNull property first, to determine if the result of this method is safe to dereference. Use with care!

Operators

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

Compares two values to determine equality.

public static bool operator ==(NullableRefReadOnly<T> left, NullableRefReadOnly<T> right)

Parameters

left NullableRefReadOnly<T>

The value to compare with right.

right NullableRefReadOnly<T>

The value to compare with left.

Returns

bool

true if left is equal to right; otherwise, false.

operator ==(NullableRefReadOnly<T>, NullableRef<T>)

Compares two values to determine equality.

public static bool operator ==(NullableRefReadOnly<T> left, NullableRef<T> right)

Parameters

left NullableRefReadOnly<T>

The value to compare with right.

right NullableRef<T>

The value to compare with left.

Returns

bool

true if left is equal to right; otherwise, false.

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

Compares two values to determine inequality.

public static bool operator !=(NullableRefReadOnly<T> left, NullableRefReadOnly<T> right)

Parameters

left NullableRefReadOnly<T>

The value to compare with right.

right NullableRefReadOnly<T>

The value to compare with left.

Returns

bool

true if left is not equal to right; otherwise, false.

operator !=(NullableRefReadOnly<T>, NullableRef<T>)

Compares two values to determine inequality.

public static bool operator !=(NullableRefReadOnly<T> left, NullableRef<T> right)

Parameters

left NullableRefReadOnly<T>

The value to compare with right.

right NullableRef<T>

The value to compare with left.

Returns

bool

true if left is not equal to right; otherwise, false.