I know I could do this with loops (as a matter of fact, I currently am, but I am trying to learn / imporve my Linq skills and i also hope it will provide a more efficent sol
I only C#, not VB. Apologies in advance.
Let's start by making a single list of anonymous objects with properties teacher, sex, name:
var singleList = lstTeachers
.Zip(lstStudentsSex, (teacher, sex) => new {teacher, sex})
.Zip(lstStudentName, (x,name) => new {x.teacher, x.sex, name})
Now we can turn this into a Dictionary of Dictionaries:
singleList
.GroupBy(x => x.teacher)
.ToDictionary(
g => g.Key,
g => g.ToDictionary(x => x.sex, x => x.name))
See @nawfal's for a corrected version of my code.