SPContentTypeId.IsParentOf method
會指出目前的內容類型識別碼 (ID) 是否父代為指定的內容類型識別碼。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
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
)
參數
id
Type: Microsoft.SharePoint.SPContentTypeId內容類型識別碼進行比較目前的內容類型識別碼。
傳回值
Type: System.Boolean
true如果目前的內容類型識別碼為父代做為引數 ; 傳遞的識別碼否則,請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的內容類型識別碼值中傳遞為引數是目前的內容類型識別碼的值相同如下列範例所示。
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中引數就目前物件的值相同傳遞的物件的值時的行為與一致。
若要判斷的即時父代的內容類型識別碼,請使用Parent屬性。
請參閱
參照
Microsoft.SharePoint namespace