请帮助LINQ,C#中的字典理解

Ham*_*jan 2 linq dictionary list-comprehension

Python相当于我想要的是:

>>> #C#: Dictionary<int, string> tempDict = ...
>>> tempDict = {i : str(i) for i in range(200000)}
>>> tempDict[5]
'5'
>>> 
Run Code Online (Sandbox Code Playgroud)

这个例子有点简化,但我可以自己修改; 不想打扰专有类的细节.

得到它了:

var y = (from x in Enumerable.Range(0, 20000) select Guid.NewGuid()).ToDictionary(g=>g, g=>new MyObj(g))
Run Code Online (Sandbox Code Playgroud)

Joe*_*oey 9

Enumerable.Range(0, 200000).ToDictionary(x => x, x => x.ToString())
Run Code Online (Sandbox Code Playgroud)

也许?