Je possède ce code:C# Afficher les éléments IEnumerable
static void Main(string[] args)
{
IEnumerable<IEnumerable<int>> result = GetCombinations(Enumerable.Range(1, 3), 2);
}
static IEnumerable<IEnumerable<T>> GetCombinations<T>(IEnumerable<T> list, int length)
{
if (length == 1) return list.Select(t => new T[] { t });
return GetCombinations(list, length - 1)
.SelectMany(t => list, (t1, t2) => t1.Concat(new T[] { t2 }));
}
La question est, comment je peux montrer tous les éléments de IEnumerable<IEnumerable<int>> result
Qu'entendez-vous par "show"? –
Soemthing comme Console.WriteLine (résultat [n]); – mdieod