Getting all possible combinations from a list of numbers
Not my code, but you’re looking for the powerset. Google gave me this solution, which seems t work: public IEnumerable<IEnumerable<T>> GetPowerSet<T>(List<T> list) { return from m in Enumerable.Range(0, 1 << list.Count) select from i in Enumerable.Range(0, list.Count) where (m & (1 << i)) != 0 select list[i]; } Source: http://rosettacode.org/wiki/Power_set#C.23