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
- FusionWrap.cs
- RoutedEventValueSerializer.cs
- Assign.cs
- TraceSource.cs
- HostingEnvironmentWrapper.cs
- TwoPhaseCommit.cs
- ContentElement.cs
- SafeEventLogWriteHandle.cs
- InputScopeAttribute.cs
- TextMetrics.cs
- ErrorRuntimeConfig.cs
- GuidConverter.cs
- ToolStripSeparator.cs
- PropertyGeneratedEventArgs.cs
- BooleanExpr.cs
- XPathMultyIterator.cs
- IApplicationTrustManager.cs
- View.cs
- PictureBoxDesigner.cs
- DataControlFieldCollection.cs
- Signature.cs
- StringFunctions.cs
- LinearGradientBrush.cs
- TextAction.cs
- KeyEventArgs.cs
- UInt16Converter.cs
- XmlAggregates.cs
- ContainerAction.cs
- DataIdProcessor.cs
- ComAdminInterfaces.cs
- BufferModeSettings.cs
- StyleBamlTreeBuilder.cs
- VisualTarget.cs
- ExpressionQuoter.cs
- IndexedGlyphRun.cs
- FileLevelControlBuilderAttribute.cs
- IsolatedStorageSecurityState.cs
- PointLightBase.cs
- AnimationClock.cs
- SynchronizedInputHelper.cs
- XhtmlBasicCommandAdapter.cs
- SerializableAttribute.cs
- ConfigXmlCDataSection.cs
- EdmFunction.cs
- AuthStoreRoleProvider.cs
- PictureBox.cs
- SettingsAttributeDictionary.cs
- DockPatternIdentifiers.cs
- DrawListViewItemEventArgs.cs
- FontSourceCollection.cs
- DoubleAnimation.cs
- CompositeDispatchFormatter.cs
- IIS7WorkerRequest.cs
- RuleInfoComparer.cs
- XmlReflectionImporter.cs
- UserControlCodeDomTreeGenerator.cs
- ContextInformation.cs
- LinkClickEvent.cs
- PersonalizationDictionary.cs
- AppSettingsExpressionBuilder.cs
- SevenBitStream.cs
- OrderedDictionaryStateHelper.cs
- HttpPostedFile.cs
- Dynamic.cs
- DictationGrammar.cs
- SortKey.cs
- DependencyObjectType.cs
- EntryIndex.cs
- DataServiceRequestOfT.cs
- LOSFormatter.cs
- SpellerInterop.cs
- WizardPanel.cs
- HealthMonitoringSectionHelper.cs
- ProfileParameter.cs
- QueryInterceptorAttribute.cs
- Sentence.cs
- AspNetSynchronizationContext.cs
- CommonRemoteMemoryBlock.cs
- SqlCharStream.cs
- ButtonChrome.cs
- Tracking.cs
- BuildProvider.cs
- Msmq.cs
- Classification.cs
- BitConverter.cs
- BaseCodePageEncoding.cs
- ObjectHelper.cs
- UIElementIsland.cs
- TimeEnumHelper.cs
- TemplateComponentConnector.cs
- ClientUtils.cs
- WindowVisualStateTracker.cs
- OleStrCAMarshaler.cs
- IncrementalReadDecoders.cs
- CheckBoxList.cs
- AspNetHostingPermission.cs
- WindowsTokenRoleProvider.cs
- SqlCacheDependencySection.cs
- PackageRelationshipCollection.cs
- MultipleViewProviderWrapper.cs