Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

[CMD] Token-Maker Problem

$
0
0
Code:
        static void Main(string[] args)
        {
            var total = 0;
            var result = "";
            do
            {
 
                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\TestFolder\WriteLines2.txt", true))
                {
                    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                    var random = new Random();
                    result = new string(
                        Enumerable.Repeat(chars, 30)
                                  .Select(s => s[random.Next(s.Length)])
                                  .ToArray());
                    Console.WriteLine(result);
                    file.WriteLine(result);
                    total++;
                }
            } while (total < 30);
        }


What it should do:
It should make 30 different tokens.

What it does:
It makes 1 key repeats it about 10 times makes another repeats it again for 10 times and again.

What is wrong?
I dont really know as i've just started messing with .Linq and files. I dont ask for any code i just want to know what the problem might be and what path should i take for solving this problem.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>