我正在嘗試創(chuàng)建一個帶有字符串鍵和元組值(字符串,布爾值)的字典。我想讓元組成為一個命名的元組,比如:Dictionary<string, (string, bool)> spColumnMapping = new Dictionary<string, (string, bool)>();是否可以?
1 回答

慕姐4208626
TA貢獻1852條經(jīng)驗 獲得超7個贊
void Main()
{
Dictionary<string, (string Foo, bool Bar)> spColumnMapping = new Dictionary<string, (string, bool)>();
spColumnMapping.Add("foo", ("Quax", false));
var x = spColumnMapping["foo"];
Console.WriteLine(x.Foo); // prints Quax
Console.WriteLine(x.Bar); // prints False
}
只需在類型后命名參數(shù)。
- 1 回答
- 0 關(guān)注
- 217 瀏覽
添加回答
舉報
0/150
提交
取消