This documentation is archived and is not being maintained.

Cache.Count Property

Gets the number of items stored in the cache.

[Visual Basic]
Public ReadOnly Property Count As Integer
[C#]
public int Count {get;}
[C++]
public: __property int get_Count();
[JScript]
public function get Count() : int;

Property Value

The number of items stored in the cache.

Remarks

This property can be useful when monitoring your application's performance or when using ASP.NET tracing functionality.

Example

[Visual Basic, C#] The following example obtains the value of the Count property, converts it to a string, and assigns the string to the Text property of a Label Web server control, Label1.

[Visual Basic] 
' Convert the Count property to a string
' and display its value in a Label server control.    
 Label1.Text = "The number of items in the cache:" + Cache.Count.ToString()

[C#] 
// Convert the Count property to a string
// and display its value in a Label server control. 
Label1.Text = "The number of items in the cache:" + Cache.Count.ToString();

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Cache Class | Cache Members | System.Web.Caching Namespace

Show: