Struct Ref<T>
Wrapper for by-ref argument.
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, A, R>, Function<A, R>, Procedure<T, A>, Procedure<A> 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<D>(ConstructorInfo) or Unreflect<D>(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. |
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. |
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. |