SPContentType constructor (SPContentType, SPContentTypeCollection, String)

Initializes a new instance of the SPContentType class using the specified parent content type.

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

public SPContentType(
	SPContentType parentContentType,
	SPContentTypeCollection collection,
	string name


Type: Microsoft.SharePoint.SPContentType

The content type from which this content type is derived.

Type: Microsoft.SharePoint.SPContentTypeCollection

The collection to which this content type is added.

Type: System.String

The name of the content type. This string is set as the value of the Name property in the new content type.


The collection cannot be modified.


The SPList on which the parentContentType resides is null .


The parentContentType has been removed from its parent SPContentTypeCollection.

The collection object that you pass as the second argument to the constructor is used to obtain certain initial values for properties of the new content type. However, the new content type is not automatically added to the collection. You must do that yourself in a subsequent call to the Add(SPContentType) method.

This constructor sets the value of the new object’s Name property to the value passed in the name argument.

The following example creates a content type that is derived from the “Item” type and then adds the new type to the site collection.

SPSite site = new SPSite("http://localhost");
SPWeb web = site.OpenWeb();

// Get a reference to the site content type collection.
SPContentTypeCollection contentTypes = web.ContentTypes;

// Create a Customer content type derived from the Item content type.
SPContentType contentType = new SPContentType(contentTypes["Item"], contentTypes, "Customer");

// Add the content type to the site collection.
contentType = contentTypes.Add(contentType);

// Clean up.