Get And Set Value By Field Internal Name

This show how to get or set field value by Internal Name. Very useful when you work with localiztion.

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

Get value by internal name
/// /// Gets the value of a sharepoint list item by internal name. /// /// Some SP List item /// Some_x0020_Column_x0020_Name /// public object GetValueInternalName(SPListItem item, string fieldInternalName) {    if (item == null) throw new ArgumentNullException("item"); if (item.Fields.ContainsField(fieldInternalName)) {        SPField field = item.Fields.GetFieldByInternalName(fieldInternalName); if (item[field.Id] != null || string.IsNullOrEmpty(field.DefaultValue)) return item[field.Id]; else if (field.FieldValueType == typeof(Boolean)) return bool.Parse((field.DefaultValue == "0") ? bool.FalseString : bool.TrueString); else return Convert.ChangeType((field.DefaultValueTyped != null) ? field.DefaultValueTyped : field.DefaultValue, field.FieldValueType); }    return null; }

Set value by internal name
public void SetValueInternalName(SPListItem item, string fieldInternalName, object value) {    SPField field = item.Fields.GetFieldByInternalName(fieldInternalName); if (value is DateTime && (DateTime)value == DateTime.MinValue) item[field.Id] = null; else item[field.Id] = value; }