title: c# returning array from function gives same result when recalled
body: <p>Got an issue where my code will generate numbers for the user and then generate numbers to compare against, although when I call this multiple times it always comes out with the same numbers even though it is supposed to be random for each call.</p>
  
  <p>An example of my output is:</p>
  
  <p>17,41,47,46,21,39,18</p>
  
  <p>And when I call the function again I get the same output as above even though I call the function again which should produce new numbers</p>
  
  <p>Menu options:</p>
  
  <pre><code>case 1:
      ticketNumbers = PlayerPickNumbers();
      CheckWinningTicket(ticketNumbers);
      break;
  case 2:
      ticketNumbers = AIPickNumbers();
      CheckWinningTicket(ticketNumbers);
      break;
  </code></pre>
  
  <p>Random number method....</p>
  
  <pre><code>static int[] AIPickNumbers() 
      {
          int[] numbersPicked = new int[7]; // Digit 7 is bonus ball
          int randomPicked = 0;
          Random rnd;
          rnd = new Random();
  
          for (int i = 0; i &lt; 7; i++)
          {
  
              randomPicked = rnd.Next(1, 50);
  
              while (numbersPicked.Contains(randomPicked) == false)
              {
                  numbersPicked[i] = randomPicked;
              }
  
              Console.Write(randomPicked + ",");
          }
          Console.WriteLine();
  
          return numbersPicked;
      }
  </code></pre>
  
  <p>Winning Ticket method... </p>
  
  <pre><code>static void CheckWinningTicket(int[] userNumbers)
      {
          int[] winningNumbers = new int[7];
          winningNumbers = AIPickNumbers(); // Generate winning numbers to compare against
          int[] userPickedNumbers = new int[7];
          userPickedNumbers = userNumbers;
  
          int totalmatches = 0;
  
          totalmatches = winningNumbers.Intersect(userPickedNumbers).Count();
  
          Console.WriteLine("You had " + totalmatches + " match(es)");
  
  
      }
  </code></pre>
  
  <p>I think the issue is when random is createdit is being created too fast and as such will always return the same numbers but not 100% sure.</p>