SPContentTypeId.IsChildOf method

Indicates whether the specified content type identifier (ID) is a descendant of the current content type ID.

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

Syntax

'Declaration
Public Function IsChildOf ( _
    id As SPContentTypeId _
) As Boolean
'Usage
Dim instance As SPContentTypeId
Dim id As SPContentTypeId
Dim returnValue As Boolean

returnValue = instance.IsChildOf(id)
public bool IsChildOf(
    SPContentTypeId id
)

Parameters

Return value

Type: System.Boolean
true if the current content type ID is derived from the specified content type ID; otherwise, false.

Remarks

This method returns true for all predecessors of the current content type ID, not just the immediate predecessor. For example, each of the last two lines of code in the following example contains an expression that evaluates to true.

SPContentTypeId x = SPBuiltInContentTypeId.Item;
SPContentTypeId y = SPBuiltInContentTypeId.Document;
SPContentTypeId z = SPBuiltInContentTypeId.BasicPage;

Console.WriteLine(z.IsChildOf(y)); // True
Console.WriteLine(z.IsChildOf(x)); // True
Dim x As SPContentTypeId = SPBuiltInContentTypeId.Item
Dim y As SPContentTypeId = SPBuiltInContentTypeId.Document
Dim z As SPContentTypeId = SPBuiltInContentTypeId.BasicPage

Console.WriteLine(z.IsChildOf(y)) ' True
Console.WriteLine(z.IsChildOf(x)) ' True

In addition, the method also returns true if the value of the content type ID passed in as an argument is the same as the value of the current content type ID, as shown in the following example.

y = x;
Console.WriteLine(x == y);         // True
Console.WriteLine(y.IsChildOf(x)); // True
Console.WriteLine(x.IsChildOf(y)); // True 
y = x
Console.WriteLine(x = y) ' True
Console.WriteLine(y.IsChildOf(x)) ' True
Console.WriteLine(x.IsChildOf(y)) ' True

See also

Reference

SPContentTypeId structure

SPContentTypeId members

Microsoft.SharePoint namespace

FindCommonParent

IsParentOf

Other resources

Content Type IDs

Base Content Type Hierarchy