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){}
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){}
In both of the above examples cnCache represents an open CacheConnection object.