SPContentTypeId.Equals 方法

确定当前SPContentTypeId对象是否等于 (可能的未知类型) 的另一个对象。

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

语法

声明
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
    类型:System.Object

    对象进行比较当前内容类型 id。

返回值

类型: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

如果参数是空引用(无 在 Visual Basic 中)或不是对象的类型SPContentTypeId, SPContentTypeId.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 结构

SPContentTypeId 成员

Microsoft.SharePoint 命名空间

Equality

CompareTo

其他资源

Content Type IDs

Base Content Type Hierarchy