Programming Combinations of a string array

ang
Newbie Member
2Jun2006,04:43   #1
ang's Avatar
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.
Team Leader
2Jun2006,14:54   #2
coderzone's Avatar
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.
Go4Expert Founder
2Jun2006,16:16   #3
shabbir's Avatar
Please read Before you make a query.
Newbie Member
1Dec2007,00:31   #4
dotnetrobert.com's Avatar
Hope this Link Helps

<<Self promotion link dropped.>>

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