SharePoint: Updating content type of a list item

Following code updates the content type of items in Announcements list to "Company Announcements" content type:

SPList oList = web.Lists["Announcements"];                  
foreach (SPListItem oListItem in oList.Items)
{
    oListItem[SPBuiltInFieldId.ContentTypeId] = oList.ContentTypes["Company Announcements"].Id; 

    // Content type can also be updated using name.
    // oListItem[SPBuiltInFieldId.ContentType] = oList.ContentTypes["Company Announcements"].Name;                                              
    oListItem.Update();
}