我想转换
List<Tuple<IntPtr, string, string>>
Run Code Online (Sandbox Code Playgroud)
成
Dictionary<IntPtr, Tuple<string,string>>
Run Code Online (Sandbox Code Playgroud)
运用
ToDictionary
Run Code Online (Sandbox Code Playgroud)
即
var T = new List<Tuple<IntPtr, string, string>>();
T.ToDictionary(/*I cannot figure out the right syntax*/);
Run Code Online (Sandbox Code Playgroud)
我找到的所有例子只有2个参数,而我有3个.
您应该使用Enumerable.ToDictionary重载,它接受键和值选择器:
T.ToDictionary(t => t.Item1, t => Tuple.Create(t.Item2, t.Item3))
Run Code Online (Sandbox Code Playgroud)
但请记住,列表中不应存在重复的指针.
| 归档时间: |
|
| 查看次数: |
156 次 |
| 最近记录: |