Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear Friend,
Can any body help me to create a function which will generate a string containing
8 character. It must be combination of alphanumeric always.

Please help me on this.
Posted

C#
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
var result = new string(
    Enumerable.Repeat(chars, 8)
              .Select(s => s[random.Next(s.Length)])
              .ToArray());


refer This[^]
 
Share this answer
 
We don't do your homework!
Try it yourself, you may find it is not as difficult as you think...
 
Share this answer
 
Did you do even the minimum rersearch - type your question into google [^]and get some excellent descriptions and sample code.

This has been solved many times already.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900