-1
StrManagers = string.Empty;

foreach (Manager manager in Managers)
{
 StrManagers = manager.Name + "</br>";
}

How can I achieve this using Linq?

Gopi
  • 5,656
  • 22
  • 80
  • 146

1 Answers1

4

You could use the String.Join method:

String.Join("</br>", Managers.Select(manager => manager.Name));
Christos
  • 53,228
  • 8
  • 76
  • 108
  • Doesn't it join Manager instead of Manager.name? – Gopi Apr 27 '15 at 11:51
  • This will join the names of the managers. Actually, this `Managers.Select(manager => manager.Name)` defines a sequence of the manager names. – Christos Apr 27 '15 at 11:52