473,385 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to generate a alpha or a digit randomly?

ad
From the past posted, I know

char c = (char)rnd.Next('a', 'z' + 1);
can generate a alpha randomly.

But now I want to generate a alpha or a digit randomly. ('0'..'9' or
'a'..'z')

How can I do?
Dec 3 '06 #1
1 1460
On Sun, 3 Dec 2006 19:50:14 +0800, "ad" <fl****@wfes.tcc.edu.tw>
wrote:
>From the past posted, I know

char c = (char)rnd.Next('a', 'z' + 1);
can generate a alpha randomly.

But now I want to generate a alpha or a digit randomly. ('0'..'9' or
'a'..'z')

How can I do?
char RandomChar() {
const string characters = "abcdefghijklmnopqrstuvwxyz0123456789";
return characters[rnd.Next(0, characters.Length)];
}

rossum

Dec 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Abby Lee | last post by:
{ if (str.length != 3) return false; else if (str.charAt(0) != ) return false; else if (!Is_Digit(str.charAt(1))) return false; else if (!Is_Digit(str.charAt(2))) return false; else return...
2
by: Henry | last post by:
Hi, How can I generate an eight digit random? Can I use the staff name to generate it? May I ask is there any sample c# code to see? Thanks
11
by: Zeya | last post by:
I need to randomly generate a 16 digit hex number in C# code. How can I do this? Thanks.
28
by: Rob Cowie | last post by:
Hi all, I wish to generate a sequence of the form 'aaa', 'aab', aac'.... 'aba', 'abb', 'abc' etc. all the way to 'zzz'. How would you construct a generator to acheive this? A simple,...
15
by: Orchid | last post by:
Hello, I am looking to generate a unique ID field on MS. Access. The ID is with 10 digits with the combination of 5 Letters from the 26 letters and 5 Numbers from 1 to 9. The letters and numbers...
7
by: ad | last post by:
Hi, How can a generate an alpha a - z randomly?
8
by: Marc | last post by:
Hi all, I have to generate and send to a printer many 6 digit alphanumeric strings. they have to be unique but I cannot check in a database or something like that if it have already been printed....
13
by: gamernaveen | last post by:
I am coding a script , where basically the user has to enter his name , choose file , file comments if required and upload. The file comments , name , filename will be stored in the database with...
5
by: ard9232 | last post by:
I"m really really confused on how to do this problem. I need to use math.random and type-casting to print out 20 license plates but I'm just really lost. Can anyone help me out? Use Java’s...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.