SPContentTypeId.GetHashCode Method
Returns a hash code for the current content type identifier (ID).
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Overrides Function GetHashCode As Integer
'Usage
Dim instance As SPContentTypeId
Dim returnValue As Integer
returnValue = instance.GetHashCode()
public override int GetHashCode()
Return Value
Type: System.Int32
The hash code for the current object.
Remarks
If two SPContentTypeId objects compare as equal, the GetHashCode method returns the same value for both objects.
Examples
The following example shows a console application that uses hash codes to determine if two SPContentTypeId objects are identical.
Imports System
Imports Microsoft.SharePoint
Module Test
Sub Main()
Dim x As SPContentTypeId = SPBuiltInContentTypeId.Announcement
Dim y As SPContentTypeId = web.Lists("Announcements").ContentTypes("Announcement").Id
Dim z As SPContentTypeId = y.Parent
Console.WriteLine(y.GetHashCode() = x.GetHashCode())
Console.WriteLine(z.GetHashCode() = x.GetHashCode())
Console.Write(vbCrLf + "Press ENTER to continue...")
Console.ReadLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
SPContentTypeId x = SPBuiltInContentTypeId.Announcement;
SPContentTypeId y = web.Lists["Announcements"].ContentTypes["Announcement"].Id;
SPContentTypeId z = y.Parent;
Console.WriteLine(y.GetHashCode() == x.GetHashCode());
Console.WriteLine(z.GetHashCode() == x.GetHashCode());
Console.Write("\nPress ENTER to continue...");
Console.ReadLine();
}
}
}
The application prints the following output to the console.
False
True
Press ENTER to continue...
See Also
Reference
Microsoft.SharePoint Namespace