1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Programming Combinations of a string array

Discussion in 'C#' started by ang, Jun 2, 2006.

  1. ang

    ang New 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.
     
  2. coderzone

    coderzone Super Moderator

    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.
     
  3. shabbir

    shabbir Administrator Staff Member

    Please read [thread=168]Before you make a query[/thread].
     
  4. dotnetrobert.com

    dotnetrobert.com New Member

    Hope this Link Helps

    <<Self promotion link dropped.>>
     
    Last edited by a moderator: Dec 1, 2007

Share This Page