My List collection like below
List<Class> classes = new List<Class>()
{
new Class()
{
className = "A",
students = new List<Student>()
{
new Student{ name="SA"},
new Student{ name="SB"},
new Student{ name="SC"},
}
},
new Class()
{
className = "B",
students = new List<Student>()
{
new Student{ name="SD"},
new Student{ name="SA"},
new Student{ name="SA"},
}
}
}
I want the Distinct student name from the classes Using Linq in the format List<string>. I tried to get in single linq query but get like., List<List<string>>. I need List<string>.
It should be something like:
The SelectMany merges the
List<Student>, the secondSelectselects only the Name of the student.