Click here to Skip to main content
15,918,485 members
Home / Discussions / C#
   

C#

 
AnswerRe: Control is locked, how to unlock? Pin
Guffa28-Aug-07 6:25
Guffa28-Aug-07 6:25 
GeneralRe: Control is locked, how to unlock? [modified] Pin
Jordanwb28-Aug-07 14:53
Jordanwb28-Aug-07 14:53 
GeneralRe: Control is locked, how to unlock? Pin
Guffa28-Aug-07 21:03
Guffa28-Aug-07 21:03 
GeneralRe: Control is locked, how to unlock? Pin
Jordanwb29-Aug-07 7:43
Jordanwb29-Aug-07 7:43 
AnswerRe: Control is locked, how to unlock? Pin
Guffa29-Aug-07 11:59
Guffa29-Aug-07 11:59 
QuestionRandom Number Pin
Imran Adam28-Aug-07 5:34
Imran Adam28-Aug-07 5:34 
AnswerRe: Random Number [modified] Pin
Alaric_28-Aug-07 6:05
professionalAlaric_28-Aug-07 6:05 
AnswerRe: Random Number Pin
originSH28-Aug-07 6:10
originSH28-Aug-07 6:10 
Random rnd = new Random();
rnd.Next();

easier than what? :P

Two lines is neither Hard nor Complex.

I suppose you could make your own method that would allow you to turn your 2 lines into 1, but I don't think it'll save you much devlopment time!

Random needs a seed and so needs to be constructed as you might want the same seed as a previous time or a new seed.
You then need to get each random number so a method call is needed, which also has multiple overloads so you can specifiy the number range if you wish.

If you want to remove all the flexability provided by the different parameters you can pass to the constructor and method then go ahead Smile | :) but as I said is it really worth it to save a single line of code?

Thats assuming you only use it once of course! the more times you use rnd.Next() without creating a new instance of rnd the difference in total lines gets less and less.
GeneralRe: Random Number Pin
Yitzchok Dev28-Aug-07 10:40
Yitzchok Dev28-Aug-07 10:40 
GeneralRe: Random Number Pin
Guffa28-Aug-07 21:05
Guffa28-Aug-07 21:05 
AnswerRe: Random Number Pin
Dan Neely28-Aug-07 10:53
Dan Neely28-Aug-07 10:53 
QuestionForeColor in Combobox control Pin
polishprogrammer28-Aug-07 5:19
polishprogrammer28-Aug-07 5:19 
AnswerRe: ForeColor in Combobox control Pin
Martin#28-Aug-07 5:58
Martin#28-Aug-07 5:58 
QuestionHebrew or Arabic string in TextBox - characters are reordered automatically for displaying Pin
wex_pl28-Aug-07 4:51
wex_pl28-Aug-07 4:51 
QuestionXmlTextReader Clean Up Pin
swjam28-Aug-07 4:48
swjam28-Aug-07 4:48 
AnswerRe: XmlTextReader Clean Up Pin
Scott Dorman28-Aug-07 5:05
professionalScott Dorman28-Aug-07 5:05 
QuestionVariable transfer between different .net Programs Pin
Der M28-Aug-07 4:29
Der M28-Aug-07 4:29 
AnswerRe: Variable transfer between different .net Programs Pin
led mike28-Aug-07 4:46
led mike28-Aug-07 4:46 
AnswerRe: Variable transfer between different .net Programs Pin
DavidNohejl28-Aug-07 5:44
DavidNohejl28-Aug-07 5:44 
GeneralRe: Variable transfer between different .net Programs Pin
Der M28-Aug-07 7:08
Der M28-Aug-07 7:08 
Questiondecimal values Pin
jon-8028-Aug-07 3:56
professionaljon-8028-Aug-07 3:56 
AnswerRe: decimal values Pin
Colin Angus Mackay28-Aug-07 4:13
Colin Angus Mackay28-Aug-07 4:13 
AnswerRe: decimal values Pin
Scott Dorman28-Aug-07 4:15
professionalScott Dorman28-Aug-07 4:15 
GeneralRe: decimal values Pin
Colin Angus Mackay28-Aug-07 5:22
Colin Angus Mackay28-Aug-07 5:22 
GeneralRe: decimal values Pin
Scott Dorman28-Aug-07 7:12
professionalScott Dorman28-Aug-07 7:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.