• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

Method Contains

Contains(String)

Determines whether the cache contains a specific key.

Declaration
bool Contains(string key)
Parameters
Type Name Description
System.String key

The key to locate in the cache.

Returns
Type Description
System.Boolean

true if the cache contains an element with the specified key; otherwise, false.

Remarks

In most of the cases this method's implementation is close to O(1).

Examples

The following example demonstrates how to check for containment of an item in the cache/>

 ICache cache = CacheManager.GetCache("demoCache");

if(cache.Contains("Product0"))
{
    Console.WriteLine("Item found!");
}
Exceptions
Type Condition
System.ArgumentNullException

key contains a null reference.

System.ArgumentException

key is not serializable.

Back to top Copyright © 2017 Alachisoft