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;                                              
profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts