これまでに単純配列を使用して、必要な情報を入力して取得しました。1つのConcurrentDictionaryで配列から値を入力して取得するC#
最初の例は以下の通りです:
// ===Example 1. Enter info ////
string[] testArr1 = null;
testArr1[0] = "ab";
testArr1[1] = "2";
// ===Example 1. GET info ////
string teeext = testArr1[0];
// =======================
及び第二の例:
// ====== Example 2. Enter info ////
string[][] testArr2 = null;
List<int> listTest = new List<int>();
listTest.Add(1);
listTest.Add(3);
listTest.Add(7);
foreach (int listitem in listTest)
{
testArr2[listitem][0] = "yohoho";
}
// ====== Example 2. Get info ////
string teeext2 = testArr2[0][0];
// =======================
しかし、今、私はにしようとしているが、各アレイへの識別番号を割り当てるので、私は可能性複数の異なる配列を1つのConcurrentDictionaryに指定します。
辞書の配列情報を入力して取得するにはどうすればよいですか?
見て、我々は2つの識別子と2つの辞書があります。それは自己だから上記のコードは動作しません(:
//////////Example 1
//To write info
test1.TryAdd(identifier1)[0] = "a";
test1.TryAdd(identifier1)[1] = "b11";
test1.TryAdd(identifier2)[0] = "152";
//to get info
string value1 = test1.TryGetValue(identifier1)[0];
string value1 = test1.TryGetValue(identifier2)[0];
//////////Example 2
//To write info: no idea
//to get info: no idea
PS:私はこのような何かを想像して
decimal identifier1 = 254;
decimal identifier2 = 110;
ConcurrentDictionary<decimal, string[]> test1 = new ConcurrentDictionary<decimal, string[]>();
ConcurrentDictionary<decimal, string[][]> test2 = new ConcurrentDictionary<decimal, string[][]>();
を)ConcurrentDictionaryのstring []とstring [] []に情報を入力する正しい方法は何ですか? (とそれを得るために)
私は混乱しています。達成しようとしていることは何ですか? – zmbq
"各配列に識別番号を割り当てようとしているので、ConcurrentDictionary内の異なる配列を識別することができます" – Alex