0

So i am trying to write a code, what randomly show a hungary license plate number (for example: KJI-735) in a label but in the label I only see this System.Char[]

Here is the code:

        char []lpt = new  char[7];
        for (int i = 0; i < 3; i++)
        {
            lpt[i] = Convert.ToChar(new Random().Next(65, 91));
        }
        rendszam[3] = '-';
        for (int i = 4; i < lpt.Length; i++)
        {
            int number = new Random().Next(49, 58);
            lpt[i] = Convert.ToChar(number);
        }
        String completelpt = lpt.ToString();
        lpt_label.(completelpt); 
Maksat Rahmanov
  • 377
  • 3
  • 10
viktorka4
  • 11
  • 6
  • Never put a Random constructor inside a loop. You will get the same value for each loop. – Steve Nov 13 '21 at 20:51

1 Answers1

0

.NET / C# - Convert char[] to string

string completelpt = new String(lpt)
lpt_label.(completelpt); 
Maksat Rahmanov
  • 377
  • 3
  • 10