ContentTypeCollection class

Represents a collection of Web site or list content types.

Inheritance hierarchy


Namespace:  Microsoft.SharePoint.Client
Assembly:  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)


Public NotInheritable Class ContentTypeCollection _
    Inherits ClientObjectCollection(Of ContentType)
Dim instance As ContentTypeCollection
public sealed class ContentTypeCollection : ClientObjectCollection<ContentType>


The Document library templates sample app for SharePoint shows how to use this object.


This code example initializes a custom content type, adds it to the collection of content types, and displays the names of the specified website’s content types.

using System;
using Microsoft.SharePoint.Client;

namespace Microsoft.SDK.SharePointFoundation.Samples
    class ContentTypeCollectionExample
        static void Main()

            string siteUrl = "http://MyServer/sites/MySiteCollection";

            ClientContext clientContext = new ClientContext(siteUrl);
            Web site = clientContext.Web;
            ContentTypeCollection collContentType = site.ContentTypes;

            // Initialize a new content type.
            ContentTypeCreationInformation contentInfo = new ContentTypeCreationInformation();
            contentInfo.Name = "myContentType";
            contentInfo.Description = "My custom content type";
            ContentType contentType = collContentType.Add(contentInfo);


            foreach (ContentType myType in collContentType)
                Console.WriteLine("Content Type Name: {0}", myType.Name);


Thread safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See also


ContentTypeCollection members

Microsoft.SharePoint.Client namespace