Cache.Remove(String) Метод
Определение
public:
System::Object ^ Remove(System::String ^ key);
public object Remove (string key);
member this.Remove : string -> obj
Public Function Remove (key As String) As Object
Параметры
- key
- String
Идентификатор String для элемента кэша, который будет удален.A String identifier for the cache item to remove.
Возвращаемое значение
Элемент, удаленный из Cache
.The item removed from the Cache
. Если значение в ключевом параметре не найдено, возвращает null
.If the value in the key parameter is not found, returns null
.
Примеры
В следующем примере создается RemoveItemFromCache
метод.The following example creates a RemoveItemFromCache
method. При вызове этого метода используется Item[] свойство, чтобы проверить, содержит ли кэш объект, связанный со Key1
значением ключа.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. Если это так, Remove
вызывается метод для удаления объекта.If it does, the Remove
method is called to remove the object.
public void RemoveItemFromCache(Object sender, EventArgs e) {
if(Cache["Key1"] != null)
Cache.Remove("Key1");
}
Public Sub RemoveItemFromCache(sender As Object, e As EventArgs)
If (Not IsNothing(Cache("Key1"))) Then
Cache.Remove("Key1")
End If
End Sub