I Used Random function in MVC, and Solved this Problem With Following :
Firstly created a random String Generator:
private static Random random = new Random();
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
Then created a random Number Generator:
public static int randomNoGenerator()
{
int ranNo = random.Next(1, 100000);
return ranNo;
}
Then wherever user I Called the Above Functions:
string randstrng = RandomString(3);
int pRanNo = rnd.Next(1, 9999);
var productID = randstrng + pRanNo;
1
solved Auto Generate a ProductID along with a Sting Prefix in MVC [closed]