This documentation is archived and is not being maintained.

MemoryCache::Item Property

Gets or sets a value in the cache by using the default indexer property for an instance of the MemoryCache class.

Namespace:  System.Runtime.Caching
Assembly:  System.Runtime.Caching (in System.Runtime.Caching.dll)

public:
virtual property Object^ Item[String^ key] {
	Object^ get (String^ key) override;
	void set (String^ key, Object^ value) override;
}

Parameters

key
Type: System::String
A unique identifier for the cache value to get or set.

Property Value

Type: System::Object
The value in the cache instance for the specified key, if the entry exists; otherwise, nullptr.

ExceptionCondition
ArgumentNullException

key is nullptr.

-or-

The inserted value is nullptr.

When you set this property, the value is inserted into the cache. The expiration policy for the cache entry is set to InfiniteAbsoluteExpiration. If a cache entry with a matching key already exists, its value is updated.

.NET Framework

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: