The user interface of SharePoint allows you to select or change the content type of a list item. How to do it by code?
The class SPListItem has a property ContentType but it’s readonly. I had to reflect the Microsoft.SharePoint.dll and finally used this workaround to change the content type:
void SetContentType (SPListItem aListItem, SPContentType aContentType)
{
aListItem["ContentTypeId"] = aContentType.Id;
aListItem.Update();
}