I am trying to remove a user from my SPFieldUserValueCollection
but I keep get the error
'SPFieldUserValue' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'SPFieldUserValue'
Here is my code
spWeb.AllowUnsafeUpdates = true;
string variable1 = Page.Request.QueryString["myID"];
int ListItemId = Int32.Parse(variable1);
SPUser userDeleted = SPContext.Current.Web.CurrentUser;
SPList List = spWeb.Lists["BGAG Learning Calendar"];
SPListItem ListItem = List.GetItemById(ListItemId);
SPFieldUserValueCollection FieldUserValueCollection = (SPFieldUserValueCollection)ListItem["Course Attendies"];
SPFieldUserValueCollection fieldUserValues = new SPFieldUserValueCollection();
foreach (SPFieldUserValue fieldUserValues1 in FieldUserValueCollection)
{
if (fieldUserValues1.LookupId != userDeleted.ID && fieldUserValues1.LookupValue != userDeleted.Name)
{
fieldUserValues1.Add(new SPFieldUserValue(spWeb, fieldUserValues1.LookupId, fieldUserValues1.LookupValue));
}
}
ListItem["Course Attendies"] = fieldUserValues;
ListItem.Update();
spWeb.AllowUnsafeUpdates = false;