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)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
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
id
Type: Microsoft.SharePoint.SPContentTypeIdA content type ID to compare to the current content type ID.
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
Microsoft.SharePoint Namespace