Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

コレクション : 配列

Caché 配列は、キーと値の組み合わせのコレクションです。このコードでは、CacheArrayOfStrings オブジェクトの Values コレクションに反復処理を行っています。


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

このコードでは、CacheArrayOfStrings オブジェクトの Keys コレクションに反復処理を行い、そのキーを使用して値にアクセスしています。


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){}

上記の例のどちらの場合も、cnCache は、開いている CacheConnection オブジェクトを表します。

FeedbackOpens in a new tab