?Namespaces:
using Microsoft.SharePoint.Client;
Assemblies:
Microsoft.SharePoint.Client.dll;
Microsoft.SharePoint.Client.RunTime.dll;
Code Snippet:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
namespace CSOMSamples
{
class Program
{
static void Main(string[] args)
{
//// String Variable to store the siteURL
string siteURL = "http://c4968397007/";
//// Get the context for the SharePoint Site to access the data
ClientContext clientContext = new ClientContext(siteURL);
//// Get the content type collection for the website
ContentTypeCollection contentTypeColl = clientContext.Web.ContentTypes;
//// Specifies properties that are used as parameters to initialize a new content type.
ContentTypeCreationInformation contentTypeCreation = new ContentTypeCreationInformation();
contentTypeCreation.Name = "Custom";
contentTypeCreation.Description = "Custom Content Type created using CSOM";
contentTypeCreation.Group = "Vijai Content Types";
//// Add the new content type to the collection
ContentType ct = contentTypeColl.Add(contentTypeCreation);
clientContext.Load(ct);
clientContext.ExecuteQuery();
//// Display that the content type is created.
Console.WriteLine(ct.Name + " content type is created successfully");
Console.ReadLine();
}
}
}