Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to generate the more than 10 random alphanumeric characters with 8digit ?
Posted
Comments
Herman<T>.Instance 13-May-15 4:22am    
What have you tried?
Kornfeld Eliyahu Peter 13-May-15 4:30am    
Please clarify...
You are talking about alphanumeric, which can contain letters and numbers, but you are also talking about digits, that belongs to numeric only...
So what do you want?! A random string or a random number?
venkatesh@India 13-May-15 8:12am    
A random string
Tomas Takac 13-May-15 6:28am    
What's your requirement? Give some examples of how should the generated string look like.
venkatesh@India 13-May-15 8:14am    
My requirement is when user enter the value in textbox like "10" after click the submit button generate the 10 random string.

You can try:

var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var random = new Random();
var result = new string(
Enumerable.Repeat(chars, 10)
.Select(s => s[random.Next(s.Length)])
.ToArray());
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 13-May-15 8:19am    
It is not too nice to copy-paste answers from others!
http://stackoverflow.com/questions/1344221/how-can-i-generate-random-alphanumeric-strings-in-c
venkatesh@India 13-May-15 8:24am    
I had already saw the article.Its working fine for 1 ramdom string generation but more than one not working .
There is a nice article here about random strings...
C# Random String Generator[^]
A solution I used once is calling Path.GetRandomFileName[^] method, which returns a random sting, that can be used as file name (in 8.3 format)...
 
Share this answer
 
i also try other way,


for (int i = 0; i<5; i++)
{
var random=new Random();
int[] ds = Enumerable.Range(0, a).Select(s => random.Next(00000000, 99995264)).ToArray();


ListBox1.DataSource = ds;
ListBox1.DataBind();
}
its generate the 5 random number .how to so shown the generated value in gridview.
 
Share this answer
 
v2
Comments
Maciej Los 14-May-15 4:18am    
Sounds like comment, not an 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