// random symbol Random r = new Random(); int x = 0; int y = 1000; string[] symb = new string[] { "a", "b", "c", "d", "e", "f", "g", "x", "y", "z" }; int num = r.Next(x,y); string snum = Convert.ToString(num); Console.WriteLine(snum); string generate = ""; string[] gen = new string[10]; for (int i = 0; i < 10; i++) { if (snum.Contains(""+i)) { gen[i] = symb[i]; generate += gen[i]; } } Console.WriteLine(generate); Console.ReadLine();
A random number is generated, then it is decrypted into a character set. For example, 675 will be equal to "gxf". But there is one mistake, because of which I open this question, and that's what it is. If the numbers are repeated, he decrypts them as one letter, for example: 606 = "ez"; How to write a variable so that it writes the same letters, rather than deleting one of the 2 that were originally.