I want to combine/merge/join/whatever a list of enums, so that each item in the unified list will have two fields - the name of the enum item (string Name), and its value (TokensEnum Token):
var tokens = Enum.GetValues(typeof (TokensEnum)); var names = Enum.GetNames(typeof (TokensEnum)); var combined = InTheDarknessBindThem(tokens,names); foreach(var c in combined) MessageBox.Show(string.Format( "Token \"{0}\" value is {1}", c.Name, (int)c.Token)); How to write the body of the following method (preferably LINQ-wise)?
InTheDarknessBindThem(IEnumerable<TokensEnum> tokens, IEnumerable<string> names) { /* ... */ }
ToString()on each value to get the name? There's no need to get the names and values separately.Dictionary<string,TokensEnum>for some kind of parser, and eachenumcan be decorated with attributes (but doesn't have to..)