C# LINQ Autogenerated number or index

c#, linq

Solution

Try:

int optionNumber = 0;
var query = from Color c in Enum.GetValues(typeof(Color))
            from Vehicle v in Enum.GetValues(typeof(Vehicle))
            select new { Number = optionNumber++, Color = c, Vehicle = v };

Problem

When deriving combination,what is the possible way to generate auto generate numbers. ``` public enum Color { Red,Green,Blue } public enum Vehicle { Car,Bike } ``` (i.e) {Red,Car},{Red,Bike},{Green,Car},{Green,Bike}...... (Jon Skeet helped me to solve it). ``` var query = from Color c in Enum.GetValues(typeof(Color)) from Vehicle v in Enum.GetValues(typeof(Vehicle)) select new { Color = c, Vehicle = v }; ``` Now I want the combination like this ``` {1,Red,Car},{2,Red,Bike},{3,Green,Car},{4,Green,Bike},{5,Blue,Car},{6,Blue,Bike} ``` What is the way to generate auto numbers?

Original source