You can't declare such a dictionary type directly (there are kludges but these are for entertainment and novelty purposes only), but if your data is coming from an IEnumerable
or IQueryable
source, you can get one using the LINQ ToDictionary()
operator and projecting out the required key and (anonymously typed) value from the sequence elements:
var intToAnon = sourceSequence.ToDictionary(
e => e.Id,
e => new { e.Column, e.Localized });
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…