Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: e00d0bca35
...
compare: 9fad85f8ba
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 29, 2012
AOA Revise the upper bound of the random values.
The max value of Random.Next is EXCLUSIVE upper bound, so we should
set it as the count of the list, rather than count - 1. Otherwise the last
item is never selected.
2fa7092
@Aaronontheweb Merge pull request #2 from AOA/master
Revise the upper bound of the random values.
9fad85f
Showing with 3 additions and 3 deletions.
  1. +3 −3 Faker/Helpers/ArrayHelpers.cs
View
6 Faker/Helpers/ArrayHelpers.cs
@@ -19,7 +19,7 @@ public static T GetRandomSubSelection<T>(this IEnumerable<T> array, int start, i
var subArray = array.ToList().GetRange(start, count);
//Determine the max length of our incoming array
- var maxLength = subArray.Count - 1;
+ var maxLength = subArray.Count;
return subArray.ElementAt(R.Next(0, maxLength));
}
@@ -27,7 +27,7 @@ public static T GetRandomSubSelection<T>(this IEnumerable<T> array, int start, i
public static IEnumerable<T> GetRandomSelection<T>(this IEnumerable<T> array, int count = 1)
{
//Determine the max length of our incoming array
- var maxLength = array.Count() - 1;
+ var maxLength = array.Count();
//Create a new list to contain our selection...
var randomSelection = new List<T>();
@@ -44,7 +44,7 @@ public static IEnumerable<T> GetRandomSelection<T>(this IEnumerable<T> array, in
public static T GetRandom<T>(this IEnumerable<T> array)
{
//Determine the max length of our incoming array
- var maxLength = array.Count() - 1;
+ var maxLength = array.Count();
return array.ElementAt(R.Next(0, maxLength));
}

No commit comments for this range

Something went wrong with that request. Please try again.