3. Combinations

A combination is an unordered selection of objects from a set. For example, if the set is {apple, banana, cherry}, then the combinations containing two items are all of the subsets containing two items in any order. Those combinations are {apple, banana}, {apple, cherry}, and {banana, cherry}. This time, {apple, banana} and {banana, apple} are considered the same, so the combinations only include one of those subsets.

Write an extension method that returns a List<List<T>>, holding the combinations of a specified length from an array of items. If the specified length is zero, return all combinations of all lengths.

Write a program similar to the one shown in the following screenshot to test your method:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset