user7232539
user7232539

Reputation:

Create Tuple with more than 2 arguments

I want to convert

List<Tuple<IntPtr, string, string>>

into

Dictionary<IntPtr, Tuple<string,string>>

using

ToDictionary

i.e.

var T = new List<Tuple<IntPtr, string, string>>();
T.ToDictionary(/*I cannot figure out the right syntax*/);

All examples I could find have just 2 arguments while I have 3.

Upvotes: 0

Views: 711

Answers (1)

Sergey Berezovskiy
Sergey Berezovskiy

Reputation: 236208

You should use Enumerable.ToDictionary overload which accepts both key and value selectors:

T.ToDictionary(t => t.Item1, t => Tuple.Create(t.Item2, t.Item3))

But keep in mind, that there should not be duplicated pointers in your list.

Upvotes: 7

Related Questions