Struct Ref<T>
Wrapper for by-ref argument.
Inherited Members
Namespace: DotNext.Reflection
Assembly: DotNext.Reflection.dll
Syntax
public struct Ref<T> : IStrongBox, IEquatable<Ref<T>>
Type Parameters
Name | Description |
---|---|
T | Referenced type. |
Remarks
This type has special semantics when used as argument type for delegates Function<T, TArgs, TResult>, Function<TArgs, TResult>, Procedure<T, TArgs>, Procedure<TArgs> when using strongly typed reflection. Argument of this type means that it should be passed into reflected method or constructor by reference. In all other scenarios, including Unreflect<TDelegate>(ConstructorInfo) or Unreflect<TDelegate>(MethodInfo), this type treated as regular value type without special semantics.
Fields
| Improve this Doc View SourceValue
Gets or sets value.
Declaration
public T Value
Field Value
Type | Description |
---|---|
T |
Methods
| Improve this Doc View SourceEquals(Object)
Always returns false because two boxed references have different address.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | Other object to compare. |
Returns
Type | Description |
---|---|
Boolean | Always false. |
Overrides
Remarks
Use equality operator instead.
GetHashCode()
Gets hash code of this reference based on its address.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | Hash code of the reference. |
Overrides
Operators
| Improve this Doc View SourceEquality(Ref<T>, Ref<T>)
Identifies that two references point to the same location.
Declaration
public static bool operator ==(in Ref<T> first, in Ref<T> second)
Parameters
Type | Name | Description |
---|---|---|
Ref<T> | first | The first reference. |
Ref<T> | second | The second reference. |
Returns
Type | Description |
---|---|
Boolean | True, if both references are equal. |
Implicit(T to Ref<T>)
Obtains a reference to the value.
Declaration
public static implicit operator Ref<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | A value. |
Returns
Type | Description |
---|---|
Ref<T> | A reference to a value. |
Implicit(Ref<T> to T)
Extracts actual value from the reference.
Declaration
public static implicit operator T(in Ref<T> reference)
Parameters
Type | Name | Description |
---|---|---|
Ref<T> | reference | Typed reference. |
Returns
Type | Description |
---|---|
T | Dereferenced value. |
Inequality(Ref<T>, Ref<T>)
Identifies that two references point to different locations.
Declaration
public static bool operator !=(in Ref<T> first, in Ref<T> second)
Parameters
Type | Name | Description |
---|---|---|
Ref<T> | first | The first reference. |
Ref<T> | second | The second reference. |
Returns
Type | Description |
---|---|
Boolean | True, if both references are not equal. |
Explicit Interface Implementations
| Improve this Doc View SourceIEquatable<Ref<T>>.Equals(Ref<T>)
Declaration
bool IEquatable<Ref<T>>.Equals(Ref<T> other)
Parameters
Type | Name | Description |
---|---|---|
Ref<T> | other |
Returns
Type | Description |
---|---|
Boolean |
IStrongBox.Value
Declaration
object IStrongBox.Value { get; set; }
Returns
Type | Description |
---|---|
Object |