title: How do I sort a random list of 7 numbers out of 35?
body: <p>I want to create a lotto-game and randomly pick 7 different numbers out of 35 numbers in C#. That is what I do in the code but I do not understand how to sort the numbers in ascending order. What I do is to pick out 7 numbers from a list that has 35 numbers and now I am so confused so I need help that at least put me in another way of thinking.lf someone could hlep me with this I would be very glad. I realize that I have messed it up some with the naming. That is (for instance) I create a list (winningNumber) that contains all but the 7 random numbers I want to sort but right now I need help to sort my messy thoughts out.</p>
  <p>Here is the code.</p>
  <pre><code> using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Text;
   using System.Threading.Tasks;
  
   namespace Random_Lotto_Number_2021_05_28_SMART
   {
  class Program
  {
      static void Main(string[] args)
      {
          Random rndLottoNumber = new Random();
          List&lt;int&gt; winningNumber = new List&lt;int&gt;();
  
          for (int i = 1; i &lt;= 35; i++)
              winningNumber.Add(i);
  
          for (int i = 0; i &lt; 7; i++)
          {
              int drawnNumber = rndLottoNumber.Next(winningNumber.Count);
              //Console.ReadLine();
              Console.Write(winningNumber[drawnNumber] + &quot;,&quot;);
              winningNumber.RemoveAt(drawnNumber);
          }
          Console.WriteLine($&quot;\nThe list contains {winningNumber.Count}&quot;);
  
          foreach(int num in winningNumber)
          {
              Console.Write(num + &quot;,&quot;);
          }
  
          Console.ReadLine();
      }
  }
   }
  </code></pre>