title: C# - Choosing a Random Value From an Array with Spesific Range and Times
body: <p>I'm working on a fixture program which is at Console Application phase for now. I arranged the teams thanks to all of you :) but I can't organize the days that teams will play with each other. So I created an array named DaysReprep with 4 elements which they represents the days of the week.(i.e. 0 represents Monday,4 represents Friday,5 represents Saturday and 6 represents Sunday which teams can play match at these days.)I also created an array named dayCounts that holds how many times they created randomly. I want to choose them randomly but, when 0 chose randomly I don't want it to create randomly again. Like that, I want to generate randomly 1 for 3 times (not in a row.), 2 for 4 times (not in a row.) and 3 for 1 times.</p>
  
  <p>Here’s my code and my output,
  Any help would be appreciated. </p>
  
  <pre><code>        int[] daysReprep = new int[4] { 0, 4, 5, 6 };   //holds the representation of days(0-monday,4-friday,5-saturday,6-sunday)
          int RandomChosenDay; //random value 
          int[] dayCounters = new int[4]; //which counts which element of the daysReprep array generated by RandomChosenDay(0.element holds 0.element of daysReprep and goes so on.)
  
          for (int i = 0; i &lt; weeklyMatched.GetLength(1); i++)
          {
                RandomChosenDay = randomNum.Next(3);
  
               switch (RandomChosenDay)
              {
  
                  case 0:
  
                      if (dayCounters[0] != 1)
                      {
                          dayCounters[0]++;
                          break;
                      }
                      else {
                          RandomChosenDay = randomNum.Next(3);  
                      }
                        break;
  
  
                  case 1:
  
                      if (dayCounters[1] != 3)
                      {
                          dayCounters[1]++;
                          break;
                      }
  
                      else {
                       RandomChosenDay=randomNum.Next(3);                  
                      }
  
                      break;
  
                   case 2:
                      if (dayCounters[2] != 4)
                      {
                          dayCounters[2]++;
                          break;
                      }
  
                      else {
                        RandomChosenDay = randomNum.Next(3);
  
                      }
                      break;
                  case 3:
                      if (dayCounters[3] != 1)
                      {
                          dayCounters[3]++;
                          break;
                      }
                      else {
            RandomChosenDay = randomNum.Next(3);
                      }
                 break;
              }
  
              for(int a = 0; a &lt; daysReprep.Length; a++) //Writes the elemts of the dayCounters
              {
                  Console.WriteLine(dayCounters[a] + " ");
  
              }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/LgVIj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LgVIj.png" alt="My LeagueFixture Output"></a></p>