Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).

Collections: Arrays

Caché arrays are collections of key-value pairs. This code demonstrates iterating through the Values collection of the CacheArrayOfStrings object:


try
{
 Provider.Collections coll = Provider.Collections.OpenId(cnCache,"1");
 foreach (string val in coll.ArrayOfStrings.Values)
 {
   Console.WriteLine("Value: {0} ", val);
  }
}
catch (CacheException e){}
Copy code to clipboard

This code iterates through the Keys collection of the CacheArrayOfStrings object and uses the keys to access the values.


try
{
 Provider.Collections coll = Provider.Collections.OpenId(cnCache,"1");
 CacheArrayOfStrings stringArr = coll.ArrayOfStrings;
 foreach (string key in coll.ArrayOfStrings.Keys)
 {
   Console.WriteLine("Key: {0}: Value {1} ", key, stringArr[key]);
 } 
}
 catch (CacheException e){}
Copy code to clipboard

In both of the above examples cnCache represents an open CacheConnection object.

FeedbackOpens in a new window