Content Type

Create a SharePoint Content Type programmatically

Sometimes it is necessary to create a Sharepoint Content Type by code, specially when batch creating content types.  The following code snippet shows how a sharepoint content type can be created in C#.  I have also included some not-so-simple field types like choice and lookup. using (SPSite p_site = new SPSite(urlToSite)) { using (SPWeb p_web = p_site.OpenWeb()) { SPContentType CustomContentType = new SPContentType(p_web.AvailableContentTypes["ParentContentType"], p_web.ContentTypes, "MyContentType"); // A string Field p_web.Fields.Add("NumberColumn",