Get Values From Special SharePoint Fields

This article shows how to get the values of special SharePoint fields.

Reference
Microsoft.Sharepoint (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll)

Username/Groupname Field
string fieldName = "FieldNameGoesHere"; SPFieldUser user = (SPFieldUser)listItem.Fields.GetField(fieldName); SPFieldUserValue fieldVal = (SPFieldUserValue)user.GetFieldValue(item[fieldName].ToString); // If it is a username, return the login name, if it is a group, return the value return fieldVal.User != null ? fieldVal.User.LoginName : fieldVal.LookupValue;

Lookup Field
return new SPFieldLookupValue(item[fieldName].ToString).LookupValue;