SortedList
2 つのキーを取り、1 つの値を返すことはできますか?
私はタイプの標準を持っていますSortedList<string, double>
しかし今、値を見つけるために 2 つのキーを渡す必要がありますSortedList<string, string, double>
。
これは可能でしょうか?そうでない場合は、他の解決策を教えてください。SortedList
文字列と double を使用して作成しましたが、2 つの文字列に基づいてその double を「呼び出す」必要があることがわかりました。
List<string> StatsCheckBoxList = new List<string>();
List<string> PeriodCheckBoxList = new List<string>();
if (checkBox7.Checked)
PeriodCheckBoxList.Add(checkBox7.Text);
if (checkBox8.Checked)
PeriodCheckBoxList.Add(checkBox8.Text);
if (checkBox9.Checked)
PeriodCheckBoxList.Add(checkBox9.Text);
if (checkBox10.Checked)
PeriodCheckBoxList.Add(checkBox10.Text);
if (checkBox19.Checked)
StatsCheckBoxList.Add(checkBox19.Text);
if (checkBox35.Checked)
StatsCheckBoxList.Add(checkBox35.Text);
if (checkBox34.Checked)
StatsCheckBoxList.Add(checkBox34.Text);
// print the name of stats onto the first column:
int l = 0;
foreach (string Stats in StatsCheckBoxList)
{
NewExcelWorkSheet.Cells[ProductReturnRawData.Count + PeriodCheckBoxList.Count + 20 + l, 1] = Stats;
l++;
}
// print the time period of each stats onto the row above:
int h = 0;
foreach (string period in PeriodCheckBoxList)
{
NewExcelWorkSheet.Cells[ProductReturnRawData.Count + PeriodCheckBoxList.Count + 19, 2 + h] = period;
h++;
}
// これはデータ テーブルです。ユーザーの選択に基づいて統計名を最初の列に出力し、ユーザーの選択に基づいて期間を一番上の行に出力しました。ここで、選択された統計と期間に基づいて統計の値を呼び出す必要があります。したがって、SortedList に 2 つのキーを渡す必要があります。何かのようなもの:
NewExcelWorkSheet.Cells[ProductReturnRawData.Count + 27, 2] = Convert.ToString(productReturnValue["3 Months"]);
ここで、productReturnValue は、文字列キーを受け取り、double 値を返す SortedList です。