Get user name from a peoplegroup column “Sharepoint 2010”


public List<string> getUserNameFromPeopleGroup(SPListItem ListItem, string PeopleGroup, SPWeb objWeb)

{

List<string> strLoginName = new List<string>();

SPFieldUserValueCollection users = ListItem[PeopleGroup] as SPFieldUserValueCollection;

if (users != null)

{

foreach (SPFieldUserValue userVal in users)

{

if (userVal.User != null)

{

SPUser user = userVal.User;

strLoginName.Add(user.Name);

}

}

}

return strLoginName;

}