473,322 Members | 1,314 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,322 software developers and data experts.

Random Number Generating

I need a program that generate 5 non-duplicates random number between 1-10
as string values store in an array.

Do anybody know of any good books or websites that explain how to generator
random numbers using asp.net?

Plus If you have any coding practice ideas for the above defined project
please share them.

Thanks!
Nov 18 '05 #1
6 1602

Look at the Random class.
Nov 18 '05 #2
Leon wrote:
I need a program that generate 5 non-duplicates random number between 1-10
as string values store in an array.

Do anybody know of any good books or websites that explain how to generator
random numbers using asp.net?


Leon, in .NET you can use the Random class to generate a random number.
See the technical docs at http://tinyurl.com/5b8m4

For your particular problem I'd do the following:

(1) Create an ArrayList with 10 elements, the numbers 1 through 10
(2) In a for loop that iterates 5 times, randomly choose a number, n,
between 1 and the size of the ArrayList.
(3) Your randomly chosen number is the number at element n in the
ArrayList. Remove this element from the ArrayList and go back to step (2).

This approach guarantees you 5 unique random numbers with 5 tries. hth

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
Nov 18 '05 #3
See the following URL:

http://msdn.microsoft.com/library/de...ClassTopic.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Leon" <vn*****@msn.com> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
I need a program that generate 5 non-duplicates random number between 1-10
as string values store in an array.

Do anybody know of any good books or websites that explain how to generator random numbers using asp.net?

Plus If you have any coding practice ideas for the above defined project
please share them.

Thanks!

Nov 18 '05 #4
See System.Math.Random in the class documentation (though I don't know if a
number is really "random" if you require it not to be the same than a
previous number).

You could have an array that tells if this partiuclar number is already
taken allowing to pick a new random number. You could use use a list if you
have a bigger interval (so that you can browse already picked numbers rather
than to have a boolean for each possible number).

Patrice

--

"Leon" <vn*****@msn.com> a écrit dans le message de
news:uI**************@TK2MSFTNGP11.phx.gbl...
I need a program that generate 5 non-duplicates random number between 1-10
as string values store in an array.

Do anybody know of any good books or websites that explain how to generator random numbers using asp.net?

Plus If you have any coding practice ideas for the above defined project
please share them.

Thanks!

Nov 18 '05 #5
I want to thank all you guys for your responses! But out all the responses
which is the best way to solve my problem?

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eJ**************@TK2MSFTNGP09.phx.gbl...
See the following URL:

http://msdn.microsoft.com/library/de...ClassTopic.asp

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Leon" <vn*****@msn.com> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
I need a program that generate 5 non-duplicates random number between
1-10
as string values store in an array.

Do anybody know of any good books or websites that explain how to

generator
random numbers using asp.net?

Plus If you have any coding practice ideas for the above defined project
please share them.

Thanks!


Nov 18 '05 #6
> I want to thank all you guys for your responses! But out all the responses
which is the best way to solve my problem?
Why, Leon, you needn't ask:

http://msdn.microsoft.com/library/de...ClassTopic.asp

Microsoft, after all, DID write the "book" on .Net. That is a page from it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Leon" <vn*****@msn.com> wrote in message
news:Oa**************@TK2MSFTNGP14.phx.gbl... I want to thank all you guys for your responses! But out all the responses
which is the best way to solve my problem?

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eJ**************@TK2MSFTNGP09.phx.gbl...
See the following URL:

http://msdn.microsoft.com/library/de...ClassTopic.asp
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Leon" <vn*****@msn.com> wrote in message
news:uI**************@TK2MSFTNGP11.phx.gbl...
I need a program that generate 5 non-duplicates random number between
1-10
as string values store in an array.

Do anybody know of any good books or websites that explain how to

generator
random numbers using asp.net?

Plus If you have any coding practice ideas for the above defined project please share them.

Thanks!



Nov 18 '05 #7

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

Similar topics

2
by: vishal | last post by:
hi i want to generate a string which contains 5 characters and all 5 characters are randomly generated means it is not fixed that which string i will get after i execute function. so tell me...
6
by: VAL | last post by:
How can I make an application form that generates a unique number starting from 1001.?
2
by: user | last post by:
Hello Is there any other class for generating random numbers (beside Random) ? Thanx Michal
16
by: Leon | last post by:
I need a program that generate 5 non-duplicates random number between 1-10 as string values store in an array. Do anybody know of any good books or websites that explain how to generator random...
5
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible...
40
by: RadiationX | last post by:
I have a problem that I really don't understand at all. In my previous post I could get started on my projects I just had a few problems with syntax errors. This problem is something that I don't...
2
by: randomcz | last post by:
hi, i need help with generating random numbers; The task is to generate hundreds of random vectors, like 1,3,5,6,7 2,4,5,4,8 ... I used the current time as the random seed, but it turns...
2
by: alishaikhji | last post by:
I am working on a program which will need several different integer and float random numbers at different stages, for example: - At one point, I need a random number (float) in the range 0.1 to 10.0...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.