C# Random.Next - never returns the upper bound?
问题 random.Next(0,5) It never returns the 5 (but sometimes returns the 0.) Why? I thought these are just boundary values that can be returned. Thanks 回答1: The maxValue for the upper-bound in the Next() method is exclusive —the range includes minValue , maxValue-1 , and all numbers in between. 回答2: The documentation says the upper bound is exclusive. Exclusive means that it is not included in the possible return set. In a more mathematical notation 0 <= x < 5 in this case. 回答3: Straight from the