SharePoint: Add multiple users to Person field

Suppose there is a Person and Group column which allows multiple selections of Users. We need to set this field of a list item in code using Server Object model. This can be done by first creating SPFieldUserValue objects and then adding them to SPFieldUserValueCollection. Code sample:
using (SPSite site = new SPSite("http://aissp2013/sites/TestSite/"))
{
    SPWeb root = site.RootWeb;
    SPList list = root.Lists["XYZ"];
    SPListItem item = list.AddItem();
    item["Title"] = "From Code";
    SPUser user1 = root.EnsureUser("contoso\\aaronp");
    SPUser user2 = root.EnsureUser("contoso\\adamb");
    SPFieldUserValueCollection users = new SPFieldUserValueCollection();
    users.Add(new SPFieldUserValue(root, user1.ID, user1.LoginName));
    users.Add(new SPFieldUserValue(root, user2.ID, user2.LoginName));                
    item["Users"] = users;
    item.Update();
}
profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts

+