Share via


SPContentTypeId.Parent property

Gets the content type identifier (ID) that the current content type ID is a direct descendant of.

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

Syntax

'Declaration
Public ReadOnly Property Parent As SPContentTypeId
    Get
'Usage
Dim instance As SPContentTypeId
Dim value As SPContentTypeId

value = instance.Parent
public SPContentTypeId Parent { get; }

Property value

Type: Microsoft.SharePoint.SPContentTypeId
A content type ID that represents the parent ID.

Remarks

Content type IDs are designed to be recursive. The ID of a content type encapsulates the lineage of that content type, or the line of parent content types from which the content type inherits. Each content type ID contains the ID of the parent content type, which in turn contains the ID of that content type's parent, and so on, ultimately back to and including the root of all content type IDs, the System content type ID. By parsing the content type ID, you can determine the lineage of a content type and how two content types are related.

For more information, see Content Type IDs.

Note

The System content type ID is the parent of itself. It is also the parent of the Empty content type ID.

Examples

The following example shows a console application that traces the parentage of the ID for the built-in content type named Document.

Imports System
Imports Microsoft.SharePoint

Module ConsoleApp

    Sub Main()

        Dim child As SPContentTypeId = SPBuiltInContentTypeId.Document
        Dim parent As SPContentTypeId = child.Parent
        Dim grandparent As SPContentTypeId = parent.Parent

        Console.WriteLine(grandparent.ToString())
        Console.WriteLine(parent.ToString())
        Console.WriteLine(child.ToString())

        Console.Write(vbCrLf & "Press ENTER to continue....")
        Console.Read()
    End Sub
End Module
using System;
using Microsoft.SharePoint;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            SPContentTypeId child = SPBuiltInContentTypeId.Document;
            SPContentTypeId parent = child.Parent;
            SPContentTypeId grandparent = parent.Parent;

            Console.WriteLine(grandparent.ToString());
            Console.WriteLine(parent.ToString());
            Console.WriteLine(child.ToString());

            Console.Write("\nPress ENTER to continue....");
            Console.Read();
        }
    }
}

The application prints the following output to the console.

0x
0x01
0x0101

Press ENTER to continue...

See also

Reference

SPContentTypeId structure

SPContentTypeId members

Microsoft.SharePoint namespace

IsParentOf(SPContentTypeId)

SPBuiltInContentTypeId

Other resources

Content Type IDs

Introduction to Content Types

Site and List Content Types

Base Content Type Hierarchy