Click here to Skip to main content
15,921,028 members
Home / Discussions / C#
   

C#

 
QuestionCounting months between dates? Pin
rbaut24-Oct-06 12:08
rbaut24-Oct-06 12:08 
AnswerRe: Counting months between dates? Pin
Guffa24-Oct-06 12:15
Guffa24-Oct-06 12:15 
QuestionWhy doesn't the left mouse button work... [modified] Pin
new_phoenix24-Oct-06 11:19
new_phoenix24-Oct-06 11:19 
QuestionCollectionEditor and Generics Pin
Jamie Nordmeyer24-Oct-06 10:43
Jamie Nordmeyer24-Oct-06 10:43 
QuestionNeed to access value from app.config file Pin
Shilpa124-Oct-06 10:21
Shilpa124-Oct-06 10:21 
AnswerRe: Need to access value from app.config file Pin
Craig G Fraser24-Oct-06 20:39
Craig G Fraser24-Oct-06 20:39 
Questionrandom numbers Pin
Jad Jadallah24-Oct-06 10:18
Jad Jadallah24-Oct-06 10:18 
AnswerRe: random numbers Pin
Jim Conigliaro24-Oct-06 10:53
Jim Conigliaro24-Oct-06 10:53 
I don't think your going to get it done in one line of code. If you are trying to keep your code simple, then I would write a routine that did the job and let calling it be your one line of code. So for example, I would write a function called GetRandomValue that handled all of the work, and then simply call that function when I needed it.


private object GetRandomValue(object[] possibleValues, object illegalValue)<br />
{<br />
   Random randomIndexGenerator = new Random();<br />
   int index = randomIndexGenerator.Next(possibleValues.Length-1);<br />
   object randomValue = possibleValues[index];<br />
   while(object == illegalValue)<br />
   {<br />
      index = randomIndexGenerator.Next(possibleValues.Length-1);<br />
      randomValue = possibleValues[index];<br />
   }<br />
   return randomValue;<br />
}



GeneralRe: random numbers Pin
Jad Jadallah24-Oct-06 11:13
Jad Jadallah24-Oct-06 11:13 
AnswerRe: random numbers Pin
Guffa24-Oct-06 12:10
Guffa24-Oct-06 12:10 
GeneralRe: random numbers Pin
Jad Jadallah24-Oct-06 12:24
Jad Jadallah24-Oct-06 12:24 
AnswerRe: random numbers Pin
Guffa24-Oct-06 13:11
Guffa24-Oct-06 13:11 
AnswerRe: random numbers Pin
Guffa25-Oct-06 7:44
Guffa25-Oct-06 7:44 
GeneralRe: random numbers Pin
Jad Jadallah25-Oct-06 8:44
Jad Jadallah25-Oct-06 8:44 
Questiondelete files from a directory Pin
keroed_edmond24-Oct-06 10:18
keroed_edmond24-Oct-06 10:18 
AnswerRe: delete files from a directory Pin
Jim Conigliaro24-Oct-06 11:03
Jim Conigliaro24-Oct-06 11:03 
QuestionTransactions between layers Pin
Luis C. Lopez24-Oct-06 9:32
Luis C. Lopez24-Oct-06 9:32 
AnswerRe: Transactions between layers Pin
Dustin Metzgar24-Oct-06 9:46
Dustin Metzgar24-Oct-06 9:46 
GeneralRe: Transactions between layers Pin
Luis C. Lopez24-Oct-06 10:01
Luis C. Lopez24-Oct-06 10:01 
QuestionShould I have outlook in order to show mht file in my c# application? Pin
AngryC24-Oct-06 7:47
AngryC24-Oct-06 7:47 
AnswerRe: Should I have outlook in order to show mht file in my c# application? Pin
Dave Kreskowiak24-Oct-06 8:11
mveDave Kreskowiak24-Oct-06 8:11 
AnswerRe: Should I have outlook in order to show mht file in my c# application? Pin
bradsnobar24-Oct-06 8:43
bradsnobar24-Oct-06 8:43 
QuestionMessagebox pop up behind mainform Pin
bradsnobar24-Oct-06 7:34
bradsnobar24-Oct-06 7:34 
AnswerRe: Messagebox pop up behind mainform Pin
engsrini24-Oct-06 18:53
engsrini24-Oct-06 18:53 
QuestionTranslating key codes to a System.Windows.Forms.Keys value. Pin
Shy Agam24-Oct-06 6:25
Shy Agam24-Oct-06 6:25 

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.