これまで、私は単純な配列を使用して必要な情報を入力および取得していました。
最初の例は次のとおりです。
// ===Example 1. Enter info ////
string[] testArr1 = null;
testArr1[0] = "ab";
testArr1[1] = "2";
// ===Example 1. GET info ////
string teeext = testArr1[0];
// =======================
そして2番目の例:
// ====== 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つの辞書があります。
decimal identifier1 = 254;
decimal identifier2 = 110;
ConcurrentDictionary<decimal, string[]> test1 = new ConcurrentDictionary<decimal, string[]>();
ConcurrentDictionary<decimal, string[][]> test2 = new ConcurrentDictionary<decimal, string[][]>();
私はこのようなものを想像していました:
//////////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:上記のコードは機能しません(自作であるため)。では、ConcurrentDictionaryのstring[]とstring[] []にIDで情報を入力する正しい方法は何ですか?(そしてそれを取り出すために)