Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Misc / CompatibleIComparer.cs / 1 / CompatibleIComparer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * This class is used to create hashcodes that are Everett Compatible. * * Copyright (c) 2004 Microsoft Corporation */ namespace System.Collections.Specialized { using Microsoft.Win32; using System.Collections; using System.Runtime.Serialization; using System.Globalization; internal class BackCompatibleStringComparer : IEqualityComparer { static internal IEqualityComparer Default = new BackCompatibleStringComparer(); internal BackCompatibleStringComparer() { } //This comes from VS# 434837 and is specifically written to get backcompat public static int GetHashCode(string obj) { unsafe { fixed (char* src = obj) { int hash = 5381; int c; char* szStr = src; while ((c = *szStr) != 0) { hash = ((hash << 5) + hash) ^ c; ++szStr; } return hash; } } } bool IEqualityComparer.Equals(Object a, Object b) { return Object.Equals(a, b); } public virtual int GetHashCode(Object o) { String obj = o as string; if (obj == null) { return o.GetHashCode(); } return BackCompatibleStringComparer.GetHashCode(obj); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EnumValAlphaComparer.cs
- CommandDevice.cs
- XmlReader.cs
- WhitespaceRule.cs
- SweepDirectionValidation.cs
- DataGridViewEditingControlShowingEventArgs.cs
- CacheForPrimitiveTypes.cs
- WorkflowWebHostingModule.cs
- SafeLocalMemHandle.cs
- WebColorConverter.cs
- LocatorBase.cs
- WorkflowDefinitionDispenser.cs
- ImplicitInputBrush.cs
- XpsFont.cs
- BinaryKeyIdentifierClause.cs
- ProfileBuildProvider.cs
- MarkupCompilePass2.cs
- RequestResizeEvent.cs
- CroppedBitmap.cs
- GZipStream.cs
- UnionExpr.cs
- FileDialog_Vista.cs
- Converter.cs
- ParameterReplacerVisitor.cs
- Semaphore.cs
- LinqDataSourceView.cs
- PassportAuthentication.cs
- MouseGesture.cs
- ControlPaint.cs
- DbgCompiler.cs
- AttributeCollection.cs
- CurrentChangingEventArgs.cs
- OperationCanceledException.cs
- WorkflowPersistenceService.cs
- PropertyValueChangedEvent.cs
- DataSetMappper.cs
- DbParameterHelper.cs
- Transform3DCollection.cs
- AddressHeaderCollectionElement.cs
- SecurityUtils.cs
- WorkflowInstanceUnhandledExceptionRecord.cs
- HttpAsyncResult.cs
- WizardForm.cs
- ControlAdapter.cs
- ObjectStateFormatter.cs
- MemberInitExpression.cs
- ViewBase.cs
- UIElement3D.cs
- DbConnectionStringCommon.cs
- LoginView.cs
- GradientBrush.cs
- LinqExpressionNormalizer.cs
- WebMessageBodyStyleHelper.cs
- XmlNamespaceDeclarationsAttribute.cs
- FrameworkContentElementAutomationPeer.cs
- DataRow.cs
- X509CertificateTrustedIssuerElement.cs
- DesignerPerfEventProvider.cs
- PlatformCulture.cs
- ImplicitInputBrush.cs
- ParallelTimeline.cs
- ConsumerConnectionPoint.cs
- DesignerOptionService.cs
- GenericEnumerator.cs
- DesigntimeLicenseContextSerializer.cs
- cookiecontainer.cs
- GlyphRunDrawing.cs
- UrlParameterReader.cs
- DataGrid.cs
- Root.cs
- SliderAutomationPeer.cs
- PropertyValueChangedEvent.cs
- RequestCachingSection.cs
- CmsInterop.cs
- ModelFunctionTypeElement.cs
- BamlBinaryWriter.cs
- FontUnit.cs
- PathSegmentCollection.cs
- PackageRelationship.cs
- storepermissionattribute.cs
- CheckBoxPopupAdapter.cs
- WebPermission.cs
- ResolveCriteriaApril2005.cs
- CompoundFileDeflateTransform.cs
- Internal.cs
- FontNameConverter.cs
- RequiredAttributeAttribute.cs
- WhitespaceRule.cs
- __Error.cs
- RequestResizeEvent.cs
- GPRECT.cs
- HttpHeaderCollection.cs
- AssemblyBuilderData.cs
- DownloadProgressEventArgs.cs
- HostAdapter.cs
- RangeValidator.cs
- DirectionalLight.cs
- ScalarConstant.cs
- InvocationExpression.cs
- PreservationFileWriter.cs