Programming Combinations of a string array

ang's Avatar
ang
Newbie Member
Hi,

I like to create hashtables from a string array haviong all possible combinations.

I guess i will give examples to better explain my problem.

suppose there is a string array which we call matrix in mathematics

1 2 3

4 5 6

7 8 9

Now the combinations should be cerated and each combination will go in one hashtable

(1,4,7) (1,4,8) (1,4,9) (1,5,7) (1,5,8) (1,5,9) (1,6,7) (1,6,8) (1,6,9) (2,4,7) (2,4,8) (2,4,9) (2,5,7) (2,5,8) (2,5,9)

(2,6,7) (2,6,8) (2,6,9) (3,4,7) (3,4,8) (3,4,9) (3,5,7) (3,5,8) (3,5,9)

(3,6,7) (3,6,8) (3,6,9)

Also the matrix can be of any dimension and not just 3*3 it can be of 3*2 or 4*5 or 4*4

Please help me writting the code in c# to generate the above combinations.

Thanks in advance.
coderzone's Avatar, Join Date: Jul 2004
Team Leader
If I understand just take a 2 Dimensional array of (N x M) and initialize all to some impossible input (say -1) now nested loop through them to get the combination.

Can you put your code sample you are working on here.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Please read Before you make a query.
dotnetrobert.com's Avatar, Join Date: Dec 2007
Newbie Member
Hope this Link Helps

<<Self promotion link dropped.>>

Last edited by shabbir; 1Dec2007 at 09:27.. Reason: Self promotion link dropped.