Skip to content

Combination of Random Numbers

Paul Sejake

Asked Jul 18, 2009, 4:12 AM EDT3 answers
Share
LinkedInX
I'd like you to programme me a code that will show a combination of Random Numbers from a series of digits, e.g.i'd like all random combinations from 1-50 with a length of 8 digits,e.g. 2 45 34 23 43 12 23 22, next row: 1 35 23 15 11 46 45 22, etc....(it should show all random numbers from 1-50).

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    See http://www.daniweb.com/code/showsnippet.php?codeid=1273 I posted code there... I couldn't paste code here for some reason
    0
  • 0
    It doesn't want to run.Would the problem be that i openned it with console application and not windows application, because the part that shows errors is this one:
    1. public static string GetRandomNumberString()
    2.     {
    3.       List<int> lst = new List<int>();
    4.       for (int i1 = 1; i1 <= 50; i1++)
    5.         lst.Add(i1);
    6.  
    7.       StringBuilder result = new StringBuilder();
    8.       while (lst.Count > 0)
    9.       {
    10.         int rnd = lst[GetRandom(lst.Count)-1];
    11.         lst.Remove(rnd);
    12.         result.Append(rnd.ToString("F0"));
    13.         if (lst.Count > 0)
    14.           result.Append(" ");
    15.       }
    16.  
    17.       return result.ToString(); ;

    Please do reply as soon, its of importance to me...

    0
  • Niradhip Chakraborty
    0
     protected void Page_Load(object sender, EventArgs e)
        {
          for(int i =0; i<8 ;i++)
          {
            int intreturnValue = RandomNumber(1, 50);
          }
        }
     
    private int RandomNumber(int min, int max)
        {
            Random random = new Random();
            return random.Next(min, max);
        }
    0