Sharepoint - How to read a User field value for a list item

Assuming that you already have a reference to the list item (called "item" in the following code sample), you must first get a reference to the list field and then use the GetFieldValue method to read the actual value.

SPFieldUser userField= (SPFieldUser)item.ParentList.Fields.GetFieldByInternalName(internalName);
var fieldValue = ((SPFieldUserValue)userField.GetFieldValue((string)item[userField.InternalName]));

Note: the SPFieldUserValue class is a wrapper, the property "User" contains a reference to the actual SPUser. Also notice that my sample uses the internal name to access the field, you can change it to use the ID if you need to.


Shorter way of getting SPUser from the field is

var t = web.Lists[properties.ListId].Items.GetItemById(properties.ListItemId);    
var username = new SPFieldUserValue(web, t["Administrator"].ToString()).User.Name;