mercredi 22 décembre 2021

Randomly generating a string of letters (C and S) and numbers in c# [closed]

I tried using 1 single random generator with the logical or | but for some reason it kept giving me the wrong outcome so i had this idea for now still it takes a bit to much to make it work is there is a better code in c# that would be very helpful.

using System;
namespace Potato
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int b = 0; b < 20; b++)
            {
                int[] pic1 = new int[3];
                Random charcters1 = new Random();
                Random charcterss1 = new Random();
                Random charctersss1 = new Random();
                Random Pic20 = new Random();
                int number10 = (charcters1.Next(48, 58)) ;
                pic1[0] = number10;
                int number20 = (charcterss1.Next(65, 91));
                pic1[1] = number20;
                int number30 = charctersss1.Next(97, 123);
                pic1[2] = number30;
                int number1 = Pic20.Next(0,3);
                int chosen1 = pic1[number1];
            Console.Write((char)chosen1);
            }
        }
    }
}



Aucun commentaire:

Enregistrer un commentaire