简体   繁体   中英

Create Tuple with more than 2 arguments

I want to convert

List<Tuple<IntPtr, string, string>>

into

Dictionary<IntPtr, Tuple<string,string>>

using

ToDictionary

ie

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM