Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,003 questions

51,950 answers

573 users

How to generate 20 digits random numbers in C#

2 Answers

0 votes
using System;

class Generate20DigitsRandomNumbers_CSharp
{
    static void Main()
    {
        Random rand = new Random(); 
 
        for (int cout = 0; cout < 25; cout++) {
            string s = string.Empty;
            for (int i = 0; i < 20; i++) {
                s = String.Concat(s, rand.Next(10).ToString());
            } 
            Console.WriteLine(s); 
        }
    }
}
  
  
  
/*
  
run:
  
77234760241232795787
55491556141578882943
88013238281428022329
10882654497525975358
26323728865875170297
78431617937984756654
36583977317247032016
64959603760374313592
84485440342658886097
94970350480618820094
19934489554261334672
94654546967604595535
45483709557436573498
92097812538832730717
55048324885064625415
57316900927632342613
57478729657565171879
31451974110937973638
70435197052381032858
07844729644458227000
90359611654514892087
80061789976285894357
61209930930612199741
81199266594951178062
37967005399783949217
 
*/

 



answered Jun 18, 2019 by avibootz
edited Nov 9, 2024 by avibootz
0 votes
using System;

class Generate20DigitsRandomNumbers_CSharp
{
    static void Main()
    {
        Random rand = new Random(); 
 
        for (int cout = 0; cout < 25; cout++) {
            string s = string.Empty;
            for (int i = 0; i < 20; i++) {
                s = String.Concat(s, rand.Next(1, 9).ToString());
            } 
            decimal dec;
            if (Decimal.TryParse(s, out dec)) {
                Console.WriteLine("{0}", dec);
            }
        }
    }
}
  
  
  
/*
  
run:
  
13771145176568546372
34614348787241566774
74768371766626466646
55721525377853376811
44112286681841825664
23688727458653315687
55747754423826826124
11328331776778764321
26433858313454642655
44554423836481236188
74764233234765672877
72114845247275686723
18257763342731254625
67174312762364671435
22272186425856538324
75562817335836456263
43662261848637755452
11325558316667147751
38883765778264338515
66787385737785812476
81241483474268462828
81741221521573555373
36188518237337773648
38726844372728631754
12833738473788847721
 
*/

 



answered Nov 9, 2024 by avibootz

Related questions

1 answer 64 views
1 answer 64 views
1 answer 78 views
2 answers 233 views
1 answer 68 views
1 answer 95 views
1 answer 86 views
...