Click here to Skip to main content
14,978,008 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi... i want to generate employeeid automatically like OA_PHP_1000, OA_PHP_1001 and so on.. fro that what to do?

thanks in advance

1 solution

Use System.Random

Random r = new Random();

StringBuilder sb = new StringBuilder();
sb.Append(r.Next(0, 10000).ToString("0000"));

string result = sb.ToString();

If your're using this in a tight loop, be sure that r is declared outside the loop - otherwise you will get non-random results.

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