Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: Embed an EXE in a frame within your program Pin
Goaty6510919-Apr-13 4:14
Goaty6510919-Apr-13 4:14 
AnswerRe: Embed an EXE in a frame within your program Pin
Abhinav S18-Apr-13 21:10
Abhinav S18-Apr-13 21:10 
Questionhow can I run code dependent on a probability using a random object? Pin
raymond leadingham18-Apr-13 7:58
raymond leadingham18-Apr-13 7:58 
AnswerRe: how can I run code dependent on a probability using a random object? Pin
SledgeHammer0118-Apr-13 8:21
SledgeHammer0118-Apr-13 8:21 
GeneralRe: how can I run code dependent on a probability using a random object? Pin
raymond leadingham18-Apr-13 8:29
raymond leadingham18-Apr-13 8:29 
GeneralRe: how can I run code dependent on a probability using a random object? Pin
SledgeHammer0118-Apr-13 10:03
SledgeHammer0118-Apr-13 10:03 
AnswerRe: how can I run code dependent on a probability using a random object? Pin
dusty_dex18-Apr-13 9:00
dusty_dex18-Apr-13 9:00 
AnswerRe: how can I run code dependent on a probability using a random object? Pin
Jasmine250118-Apr-13 11:52
Jasmine250118-Apr-13 11:52 
May I suggest...

Pseudo-code...
static void function1 (MyObject o) {
   ...function operating on o...
}

static void function2 (MyObject o) {
   ...function doing some other operation on o, or no-op even...
}

void ProbabilityFunction () {
  loop {
    if (randomNumber < 0.7) {
      function1(o);
    } else {
      function2(o);
    }
  }
}


Take that pattern and expand it.

BTW, your mistake here is assuming this is more complicated than it is. You have a simple decision, with only two branches - that's the trivial IF situation. Always break down your problem to the simplest possible thing. I think you missed the fact that all you're doing here is a simple IF-ELSE, and there's NOTHING in the ELSE.

Are you planning to have more than two possible functions? Because then, yeah, you need something more complicated, and to be honest, I was hoping you were asking about that. There is a known pattern for that - where you have between 3 and millions of possible functions. When you only have two, it's an IF-ELSE.
Questionhow to change the shape of button in c# Pin
Nofar Gutman18-Apr-13 6:52
Nofar Gutman18-Apr-13 6:52 
AnswerRe: how to change the shape of button in c# Pin
SledgeHammer0118-Apr-13 8:22
SledgeHammer0118-Apr-13 8:22 
GeneralRe: how to change the shape of button in c# Pin
Nofar Gutman18-Apr-13 10:37
Nofar Gutman18-Apr-13 10:37 
AnswerRe: how to change the shape of button in c# Pin
Clifford Nelson18-Apr-13 17:02
Clifford Nelson18-Apr-13 17:02 
AnswerRe: how to change the shape of button in c# Pin
Eddy Vluggen18-Apr-13 10:00
professionalEddy Vluggen18-Apr-13 10:00 
GeneralRe: how to change the shape of button in c# Pin
Nofar Gutman18-Apr-13 10:35
Nofar Gutman18-Apr-13 10:35 
GeneralRe: how to change the shape of button in c# Pin
Eddy Vluggen18-Apr-13 10:46
professionalEddy Vluggen18-Apr-13 10:46 
AnswerRe: how to change the shape of button in c# Pin
Bernhard Hiller18-Apr-13 21:47
Bernhard Hiller18-Apr-13 21:47 
QuestionCapturing GPS data in C#.Net Pin
Sanjay K. Gupta18-Apr-13 3:12
professionalSanjay K. Gupta18-Apr-13 3:12 
SuggestionRe: Capturing GPS data in C#.Net Pin
Richard MacCutchan18-Apr-13 4:29
mveRichard MacCutchan18-Apr-13 4:29 
AnswerRe: Capturing GPS data in C#.Net Pin
Bernhard Hiller18-Apr-13 21:50
Bernhard Hiller18-Apr-13 21:50 
QuestionCount the unique number of words inside a string builder(Not letters...Words)) Pin
kanamala subin18-Apr-13 2:36
kanamala subin18-Apr-13 2:36 
AnswerRe: Count the unique number of words inside a string builder(Not letters...Words)) Pin
DaveyM6918-Apr-13 2:45
professionalDaveyM6918-Apr-13 2:45 
AnswerRe: Count the unique number of words inside a string builder(Not letters...Words)) Pin
Andreas X18-Apr-13 2:47
professionalAndreas X18-Apr-13 2:47 
AnswerRe: Count the unique number of words inside a string builder(Not letters...Words)) Pin
Clifford Nelson18-Apr-13 5:09
Clifford Nelson18-Apr-13 5:09 
GeneralRe: Count the unique number of words inside a string builder(Not letters...Words)) Pin
Jasmine250118-Apr-13 6:34
Jasmine250118-Apr-13 6:34 
GeneralRe: Count the unique number of words inside a string builder(Not letters...Words)) Pin
Eddy Vluggen18-Apr-13 10:04
professionalEddy Vluggen18-Apr-13 10:04 

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.