Random selection of eligible women in a household roster

dear Team,
I need to randomly select 1 eligible woman of age between 15 to 49 and man 15-59 from a household roster.

I modified this code according to this link:

Below is my code:
//Counting number eligible members
wnumEligible=MEMBERS.Count(x=>x.age.InRange(15,49) && x.gender==2)

//random index of eligible women

//MEMBERS.Where($x=>x.age.InRange(15,49) && x.gender==2).Select(z=>z.@rowcode).ToArray()[wrnd.Value]

//Name of randomly selected person

But my code alwasy selects the first person within the roster row based on gender and the age category form.

what might be wrong? Your advice please

I don’t see anything wrong. Please re-check your claim that “my code alwasy selects the first person within the roster row”.