anonymous1110 anonymous1110 -3 years ago 133
C# Question

Randomize LuisDialog answer

Hi guys im trying to use Random.Next to try to randomize the answer of luis. Unfortunately it doest seems to work, it always returns zero.

public async Task Age(IDialogContext context, LuisResult result)
Random random = new Random();
int randomNumber = random.Next(0, 1);
List<string> Answers = new List<string>();
Answers.Add("Are you serious?");
Answers.Add("A million!I am million years old!Any more questions?");

string message = Answers[randomNumber];
await context.PostAsync(message);


Answer Source

The problem comes from your random function. As, random.Next(m,n) is a random number >=m and <n, so random.Next(0,1) just generate 0. Hence, you should change it to random.Next(0,2).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download