Cache.Remove(String) Cache.Remove(String) Cache.Remove(String) Cache.Remove(String) Method

Definition

從應用程式的 Cache 物件移除指定的項目。 Removes the specified item from the application's Cache object.

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 String String

要移除之快取項目的 String 識別項。 A String identifier for the cache item to remove.

Returns

Cache 移除的項目。 The item removed from the Cache. 如果沒有找到索引鍵參數中的值,會傳回 null If the value in the key parameter is not found, returns null.

Examples

下列範例會建立RemoveItemFromCache方法。The following example creates a RemoveItemFromCache method. 當呼叫這個方法時,它會使用Item[String]檢查快取是否包含物件相關聯的屬性Key1機碼值。When this method is called, it uses the Item[String] 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

Applies to

See Also