Прочетете на английски Редактиране

Споделяне чрез


Cache.Remove(String) Method

Definition

Removes the specified item from the application's Cache object.

C#
public object Remove(string key);

Parameters

key
String

A String identifier for the cache item to remove.

Returns

The item removed from the Cache. If the value in the key parameter is not found, returns null.

Examples

The following example creates a RemoveItemFromCache method. When this method is called, it uses the Item[] property to check whether the cache contains an object that is associated with a Key1 key value. If it does, the Remove method is called to remove the object.

C#
public void RemoveItemFromCache(Object sender, EventArgs e) {
    if(Cache["Key1"] != null)
      Cache.Remove("Key1");
}

Applies to

Продукт Версии
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also