SPContentTypeId.IsParentOf 方法

指示当前的内容类型标识符 (ID) 是父对象指定的内容类型 id。

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Function IsParentOf ( _
    id As SPContentTypeId _
) As Boolean
用法
Dim instance As SPContentTypeId
Dim id As SPContentTypeId
Dim returnValue As Boolean

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

参数

返回值

类型:System.Boolean
true如果当前的内容类型 ID 是父对象的 ID 作为参数 ; 传递否则为false。

备注

This method returns true for all descendants of the current content type ID. (For information about content type ID lineage, see Base Content Type Hierarchy.) 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(x.IsParentOf(y)); // True
Console.WriteLine(x.IsParentOf(z)); // True
Dim x As SPContentTypeId = SPBuiltInContentTypeId.Item
Dim y As SPContentTypeId = SPBuiltInContentTypeId.Document
Dim z As SPContentTypeId = SPBuiltInContentTypeId.BasicPage

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

此外,该方法返回true如果内容类型 ID 的值传入参数是相同的值的当前的内容类型 ID,如下面的示例所示。

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

此行为是与IsChildOf方法,该对象的值传递如参数是当前对象的值相同时也会返回true方法的行为一致。

若要确定内容类型 ID 的直接父,请使用Parent属性。

另请参阅

引用

SPContentTypeId 结构

SPContentTypeId 成员

Microsoft.SharePoint 命名空间

Parent

FindCommonParent

IsChildOf

其他资源

Content Type IDs

Base Content Type Hierarchy