Q:

How can I split a list into two that can hold odd number of counts?

I have a sql list "GetStaff()" that has 9 people in it and when the code runs it splits them in two teams but only displays 4 in each team. I cannot get the 9th member to be displayed in the team.How can I adjust the code to hold odd number of people and not just even in a split team.Any help would be helpful.
public List<Staff[]> CreateTeams(int membersPerTeam)
        {
            IList<Staff> allUsers = GetStaff();
            int teamCount = allUsers.Count / membersPerTeam;
            int usersPerTeam = allUsers.Count / 2;
            var teams = new List<Staff[]>();

            for (int i = 0; i < teamCount; i++)
            {
                Staff[] team = new Staff[membersPerTeam];
                for (int j = 0; j < usersPerTeam ; j++)
                {
                    team[j] = allUsers[i * membersPerTeam + j];
                }
                teams.Add(team);
            }
            return teams;
        }

A:

I'd use LINQ:
public List<Staff[]> CreateTeams(int membersPerTeam)
{
    IList<Staff> allUsers = GetStaff();
    int teams = allUsers.Count() / membersPerTeam + allUsers.Count() % membersPerTeam == 0 ? 0 : 1;;
    return
        allUsers
            .Select((x, n) => new { x, n })
            .GroupBy(z => z.n % teams)
            .Select(zs => zs.Select(z => z.x).ToArray())
            .ToList();
}

This simply projects the list to include an n index number and then groups by the modulus of membersPerTeam against that n. Then it removes the index and returns the results.

A:

Based on @Enigmativity's answer and clarifications in comments, I'd suggest a simplyfied version of his solution:
public List<Staff[]> CreateTwoTeams() // No argument => You don't know the total number
{
    return
        GetStaff()                             // Get all members
            .Select((x, n) => new { x, n })    // add an index
            .GroupBy(z => z.n % 2)             // Create 2 Groups: Even and Odd
            .Select(zs => zs.Select(z => z.x)  // For each Group: make an array 
                             .ToArray())       // of the members
            .ToList();                         // Make a List of those arrays.
}

If you later chose to make the number of teams variable, you can simply introduce an argument and replace the hardcoded "2" by it.

