Nullable.GetValueRefOrDefaultRef<T>(Nullable<T>) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索对存储值的实例中位置的 Nullable<T> 只读引用。
public:
generic <typename T>
where T : value class static T& ^ GetValueRefOrDefaultRef(Nullable<T> % nullable);
public static ref readonly T GetValueRefOrDefaultRef<T>(ref readonly T? nullable) where T : struct;
public static ref readonly T GetValueRefOrDefaultRef<T>(in T? nullable) where T : struct;
static member GetValueRefOrDefaultRef : Nullable -> 'T (requires 'T : struct)
Public Shared Function GetValueRefOrDefaultRef(Of T As Structure) (ByRef nullable As Nullable(Of T)) As T
类型参数
- T
泛型类型的基础值类型 Nullable<T> 。
参数
- nullable
- Nullable<T>
对输入 Nullable<T> 值的只读引用。
返回
T
对存储实例 T 值的位置的只读引用。 如果实例是HasValuefalse,则位于该位置的当前值可能是默认值。
注解
当返回的只读引用引用引用存储在输入 nullable 值中的数据时,仅当输入引用指向具有实际位置的值而不是“右值”(可能出现在赋值右侧而不是左侧的表达式)时,才应调用此方法。 也就是说,如果调用此 API,并且输入引用指向编译器作为防御副本或临时副本生成的值,则行为可能与所需的值不匹配。