Random r = new Random(DateTime.Now.Millisecond);
int numberOfFoos = foos.Count;
int fooIndex1 = 0,fooIndex2 = 0;
Foo foo1 = new Foo();
Foo foo2 = new Foo();
do
{
while(fooIndex1 == fooIndex2)
{
fooIndex1 = r.Next(4);
fooIndex2 = r.Next(4);
}
foo1 = foosList[fooIndex1];
foo2 = foosList[fooIndex2];
}while(foo1.NumberOfLittleFoos == 0 || foo2.NumberOfLittleFoos == 0);
Why fooIndex1 is always 0 and fooIndex2 is always 2? I was trying to use Guid.NewGuid().GetHashCode() to generate random integers, but it still doesn't work rightly.
By this code I am trying to select 2 different Foo's from foosList.
I would be grateful for any help.
Aucun commentaire:
Enregistrer un commentaire