使用2个以上的参数创建元组

B J*_*B J 0 c# tuples

我想转换

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个.

Ser*_*kiy 7

您应该使用Enumerable.ToDictionary重载,它接受键和值选择器:

T.ToDictionary(t => t.Item1, t => Tuple.Create(t.Item2, t.Item3))
Run Code Online (Sandbox Code Playgroud)

但请记住,列表中不应存在重复的指针.