Write a function that will print all possible combinations of the given array??
ex:- if given array is : int[] arr={1,2,3,4,5}
It should print all the combinations of elements present in the array
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Karthikeyan KPosted Aug 26, 2015, 1:19 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
class Program
{
static void Main(string[] args)
{
int[] Arr = { 1, 2, 3, 4, 5 };
var combo = from a in Arr
from b in Arr
from c in Arr
select string.Concat(a,b,c);
foreach (var v in combo)
{
Console.WriteLine(v);
}
Console.ReadKey();
}
}
Rajeesh MenothPosted Aug 26, 2015, 2:00 AM
Rajeesh MenothPosted Aug 26, 2015, 12:34 AM