共用方式為


SPContentTypeId.Equals method

會決定目前SPContentTypeId物件是否等於另一個類型的物件 (可能是未知)。

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

Syntax

'宣告
Public Overrides Function Equals ( _
    o As Object _
) As Boolean
'用途
Dim instance As SPContentTypeId
Dim o As Object
Dim returnValue As Boolean

returnValue = instance.Equals(o)
public override bool Equals(
    Object o
)

參數

  • o
    Type: System.Object

    物件進行比較目前的內容類型識別碼。

傳回值

Type: System.Boolean
true如果目前的物件是等於做為引數 ; 傳遞的物件否則,請false。

備註

如果引數是類型SPContentTypeId的物件,但不等於目前SPContentTypeId物件的值的值,這個方法會傳回false 。如果兩個物件的相等的值,這個方法會傳回true 。下列程式碼所說明的行為表現方式。

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

Console.WriteLine(x.Equals(y)); // false
x = y;
Console.WriteLine(x.Equals(y)); // true
Dim x As SPContentTypeId = SPBuiltInContentTypeId.Item
Dim y As SPContentTypeId = SPBuiltInContentTypeId.Document

Console.WriteLine(x.Equals(y)) ' false
x = y
Console.WriteLine(x.Equals(y)) ' true

如果引數為a null reference (Nothing in Visual Basic)或不的物件類型SPContentTypeIdSPContentTypeId.Equals(System.Object)方法也會傳回false 。這是與CompareTo方法,需要類型SPContentTypeId引數的行為不同。下列程式碼所說明的兩個方法之間的差異。

SPContentTypeId x = SPBuiltInContentTypeId.Item;
System.Object y = x;

Console.WriteLine(x.Equals(x));    // true.
Console.WriteLine(x.Equals(y));    // true.
Console.WriteLine(x.Equals(null)); // false.

Console.WriteLine(x.CompareTo(x) == 0); // true.
Console.WriteLine(x.CompareTo((SPContentTypeId)y) == 0); // true.

Console.WriteLine(x.CompareTo(y) == 0); // Does not compile.
Console.WriteLine(x.CompareTo(null) == 0);  // Does not compile.
Dim x As SPContentTypeId = SPBuiltInContentTypeId.Item
Dim y As System.Object = x

Console.WriteLine(x.Equals(x)) ' true.
Console.WriteLine(x.Equals(y)) ' true.
Console.WriteLine(x.Equals(Nothing)) ' false.

Console.WriteLine(x.CompareTo(x) = 0) ' true.
Console.WriteLine(x.CompareTo(CType(y, SPContentTypeId)) = 0) ' true.

Console.WriteLine(x.CompareTo(y) = 0) ' Does not compile.
Console.WriteLine(x.CompareTo(Nothing) = 0) ' Does not compile.

請參閱

參照

SPContentTypeId structure

SPContentTypeId members

Microsoft.SharePoint namespace

Equality

CompareTo

其他資源

Content Type IDs

Base Content Type Hierarchy