title: Create random number and make an array from that number
body: <p>I'm making a small project using c# for my class. The program is</p>
  <ol>
  <li><p>Ask user to enter an Integer value between 2 and 9. This value gives the maximum number of digits for random number I need to generate. For example, if the user enters a 7, then the maximum will be seven nines (9999999);</p>
  </li>
  <li><p>Create a random number between 10 and that maximum value. So, if user enters a 5, then the random number will be in range (10,99999]</p>
  </li>
  <li><p>After I created the random number, I need to create an array of digits for that number: for example, if the user enters a 3, then the random number is in (10,999]. Let's say it is 271. Then I need to generate an array of digits for 271, starting from right:</p>
  </li>
  </ol>
  <pre><code>Array[0]=1
  Array[1]=7
  Array[2]=2
  </code></pre>
  <p>I tried to change the random number type to a string, so that I can determine the length of the array using that number:</p>
  <pre class="lang-cs prettyprint-override"><code>Console.WriteLine(&quot;pleas enter value  between 2 and 9&quot;);
  string s = Console.ReadLine();
  
  int v = int.Parse(s);
  int v2=99, v3=999, v4=9999, v5=99999, v6=999999, v7=9999999, v8=99999999, v9=999999999;
  if(v==2)
  {
      Console.WriteLine(&quot;Max number = &quot; + v2);
      Random randomNumber = new Random();
      int number = randomNumber.Next(10, (++v2));
      Console.WriteLine(&quot;random number &quot; + number);
      string sv =&quot;&quot;+number;
      string[] arry1 = new string [sv.Length];
      Console.WriteLine(&quot;length array is :&quot; + arry1.Length);
      Console.WriteLine(&quot;array elements:&quot;+ arry1[1]);
  }else
  {
      if (v == 3)
      {
          Console.WriteLine(&quot;Max number = &quot; + v3);
          Random randomNumber = new Random();
          int number = randomNumber.Next(10, (++v3));
          Console.WriteLine(&quot;random number &quot; + number);
          string sv = &quot;&quot; + number;
          string[] arry1 = new string[sv.Length];
          Console.WriteLine(&quot;length array is :&quot; + arry1.Length);
      }
      else
      {
          if(v==4)
          {
              Console.WriteLine(&quot;Max number = &quot; + v4);
              Random randomNumber = new Random();
              int number = randomNumber.Next(10, (++v4));
              Console.WriteLine(&quot;random number &quot; + number);
              string sv = &quot;&quot; + number;
              string[] arry1 = new string[sv.Length];
              Console.WriteLine(&quot;length array is :&quot; + arry1.Length);
          }
          else ...
  </code></pre>
  <p>I am stuck on this step. How do I fill the array using the random number I have crated before?</p>
  <p>This is how it should be:</p>
  <p><a href="https://i.stack.imgur.com/Dip7H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dip7H.png" alt="user interaction" /></a></p>
  <p>I, however, can't use any external functions or methods.</p>