CacheExtensions.TryGetValue<TItem>(IMemoryCache, Object, TItem) 方法

定义

尝试获取与指定键关联的值。

public:
generic <typename TItem>
[System::Runtime::CompilerServices::Extension]
 static bool TryGetValue(Microsoft::Extensions::Caching::Memory::IMemoryCache ^ cache, System::Object ^ key, [Runtime::InteropServices::Out] TItem % value);
public static bool TryGetValue<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, out TItem value);
public static bool TryGetValue<TItem> (this Microsoft.Extensions.Caching.Memory.IMemoryCache cache, object key, out TItem? value);
static member TryGetValue : Microsoft.Extensions.Caching.Memory.IMemoryCache * obj * 'Item -> bool
<Extension()>
Public Function TryGetValue(Of TItem) (cache As IMemoryCache, key As Object, ByRef value As TItem) As Boolean

类型参数

TItem

要获取的对象类型。

参数

cache
IMemoryCache

IMemoryCache此方法扩展的实例。

key
Object

要获取的值的键。

value
TItem

与给定键关联的值。

返回

如果找到了该键,则为 true。 否则为 false

适用于