squad303 / squad303app

Other
239 stars 34 forks source link

Rand.Next(Int32, Int32) #23

Open mazanuj opened 2 years ago

mazanuj commented 2 years ago

Your code doesn't include the last phone number from the list Link

[HttpGet]
public IActionResult Get()
{
    var randomNumber = random.Next(0, Phones.Numbers.Length - 1);
    return Ok(Phones.Numbers[randomNumber].ToString());
}

Screenshot 2022-03-19 003814

change random.Next(0, Phones.Numbers.Length - 1) to random.Next(0, Phones.Numbers.Length)

303UsefulIdiots commented 2 years ago

I would check how the count is used in the loop, this is written to start count at 0 and might not be the cause of the problem