How can i get random 10 call numbers to be generated in this format 005.73 JAM- In c# windows form

anom2002 1 Reputation point
2022-09-15T17:36:26.59+00:00

-5

How can i get random 10 call numbers to be generated in this format

005.73 JAM- In c# windows form
i tried this but i wanted to know how i can join generated string and number with decimal

const string src = "abcdefghijklmnopqrstuvwxyz0123456789";
int length = 9;
var sb = new StringBuilder();
Random RNG = new Random();
for (var i = 0; i < length; i++)
{
var c = src[RNG.Next(0, src.Length)];
sb.Append(c);
}
MessageBox.Show(sb.ToString());

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,835 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 24,296 Reputation points Microsoft Vendor
    2022-09-16T05:34:44.163+00:00

    @anom2002 , Welcome to Microsoft Q&A, Please refer to the following steps to write the code to get the wanted call numbers

    First, We could use regex to get the number string and alpha string from the source string.

    Second, We could get 5 random number from the string 0123456789.

    Third, Please insert . to the number.

    Fourth, We could get 3 random character from the string 'abcdefghijklmnopqrstuvwxyz' and upper the characters.

    Finally, We can use Stringbuilder get the result you want.

    Here is a code example you could refer to.

    code.txt

    Result:

    241650-image.png

    Best Regards,

    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments