Share via


MemoryCache.TryGetValue Method

Definition

Overloads

TryGetValue(Object, Object)

Gets the item associated with this key if present.

TryGetValue(ReadOnlySpan<Char>, Object)

Gets the item associated with this key if present.

TryGetValue<TItem>(ReadOnlySpan<Char>, TItem)

Gets the item associated with this key if present.

TryGetValue(Object, Object)

Source:
MemoryCache.cs
Source:
MemoryCache.cs
Source:
MemoryCache.cs

Gets the item associated with this key if present.

public:
 virtual bool TryGetValue(System::Object ^ key, [Runtime::InteropServices::Out] System::Object ^ % result);
public bool TryGetValue(object key, out object? result);
abstract member TryGetValue : obj * obj -> bool
override this.TryGetValue : obj * obj -> bool
Public Function TryGetValue (key As Object, ByRef result As Object) As Boolean

Parameters

key
Object

An object identifying the requested entry.

result
Object

Returns

true if the key was found.

Implements

Applies to

TryGetValue(ReadOnlySpan<Char>, Object)

Source:
MemoryCache.cs

Gets the item associated with this key if present.

public:
 bool TryGetValue(ReadOnlySpan<char> key, [Runtime::InteropServices::Out] System::Object ^ % value);
[System.Runtime.CompilerServices.OverloadResolutionPriority(1)]
public bool TryGetValue(ReadOnlySpan<char> key, out object? value);
[<System.Runtime.CompilerServices.OverloadResolutionPriority(1)>]
member this.TryGetValue : ReadOnlySpan<char> * obj -> bool
Public Function TryGetValue (key As ReadOnlySpan(Of Char), ByRef value As Object) As Boolean

Parameters

key
ReadOnlySpan<Char>

A character span corresponding to a String identifying the requested entry.

value
Object

The located value or null.

Returns

True if the key was found.

Attributes

Remarks

This method allows values with String keys to be queried by content without allocating a new String instance.

Applies to

TryGetValue<TItem>(ReadOnlySpan<Char>, TItem)

Source:
MemoryCache.cs

Gets the item associated with this key if present.

public:
generic <typename TItem>
 bool TryGetValue(ReadOnlySpan<char> key, [Runtime::InteropServices::Out] TItem % value);
[System.Runtime.CompilerServices.OverloadResolutionPriority(1)]
public bool TryGetValue<TItem>(ReadOnlySpan<char> key, out TItem? value);
[<System.Runtime.CompilerServices.OverloadResolutionPriority(1)>]
member this.TryGetValue : ReadOnlySpan<char> * 'Item -> bool
Public Function TryGetValue(Of TItem) (key As ReadOnlySpan(Of Char), ByRef value As TItem) As Boolean

Type Parameters

TItem

Parameters

key
ReadOnlySpan<Char>

A character span corresponding to a String identifying the requested entry.

value
TItem

The located value or null.

Returns

True if the key was found.

Attributes

Remarks

This method allows values with String keys to be queried by content without allocating a new String instance.

Applies to