title: generating random numbers in asp.net
body: <p>i want to generate vouchers of alpha numeric code of 10 digits and the error is 
  "cannot implicitly convert 'void' to system.collections.generric.list"</p>
  
  <p>voucher_no=   generatedVouchers.Add(voucher);//it is giving me error in this line</p>
  
  <pre><code>    static Random random = new Random();
      public ActionResult RandomVouchers()
      {
  
          int vouchersToGenerate = 1;
          int lengthOfVoucher = 10;
  
  
          List&lt;string&gt; voucher_no = new List&lt;string&gt;();
  
          List&lt;string&gt; generatedVouchers = new List&lt;string&gt;();
          char[] keys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890".ToCharArray();
  
          while (generatedVouchers.Count &lt; vouchersToGenerate)
          {
              string voucher = GenerateVoucher(keys, lengthOfVoucher);
              if (!generatedVouchers.Contains(voucher))
              {
              voucher_no=   generatedVouchers.Add(voucher);//it is giving me error in this line
  
              }
          }
          return View(voucher_no);
      }
      private static string GenerateVoucher(char[] keys, int lengthOfVoucher)
      {
  
          return Enumerable
              .Range(1, lengthOfVoucher) // for(i.. ) 
              .Select(k =&gt; keys[random.Next(0, keys.Length - 1)])  // generate a new random char 
              .Aggregate("", (e, c) =&gt; e + c); // join into a string
      }
  </code></pre>