Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Misc / CompatibleIComparer.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SpellerError.cs
- HtmlEncodedRawTextWriter.cs
- DataGridView.cs
- Pair.cs
- Security.cs
- DelegateTypeInfo.cs
- Positioning.cs
- AutomationElement.cs
- TCEAdapterGenerator.cs
- QuinticEase.cs
- CompilerCollection.cs
- RangeBase.cs
- Encoder.cs
- ThousandthOfEmRealDoubles.cs
- ContentControl.cs
- VerificationAttribute.cs
- AttributeCollection.cs
- OracleInternalConnection.cs
- LinearQuaternionKeyFrame.cs
- CodeMemberMethod.cs
- EnumMemberAttribute.cs
- PropertyChangedEventManager.cs
- ExtendedPropertyCollection.cs
- EventLevel.cs
- WebResourceUtil.cs
- TabControlCancelEvent.cs
- PageThemeBuildProvider.cs
- IsolationInterop.cs
- autovalidator.cs
- XPathAxisIterator.cs
- ProfileGroupSettings.cs
- XhtmlStyleClass.cs
- Baml6ConstructorInfo.cs
- ValueSerializerAttribute.cs
- AuthenticationConfig.cs
- ProjectionCamera.cs
- SystemInformation.cs
- SEHException.cs
- NetDataContractSerializer.cs
- _HelperAsyncResults.cs
- ImpersonateTokenRef.cs
- HelpFileFileNameEditor.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- GeneralTransform3DGroup.cs
- EdmProviderManifest.cs
- BrushValueSerializer.cs
- WindowsSlider.cs
- Currency.cs
- AsymmetricCryptoHandle.cs
- PolicyManager.cs
- ProgressBarHighlightConverter.cs
- HandleRef.cs
- XmlWrappingReader.cs
- EdmItemCollection.OcAssemblyCache.cs
- ListBase.cs
- ProbeDuplex11AsyncResult.cs
- LambdaCompiler.Binary.cs
- ManipulationDeltaEventArgs.cs
- EpmCustomContentDeSerializer.cs
- BitmapEffectDrawingContextWalker.cs
- TcpChannelHelper.cs
- WebPartMenuStyle.cs
- DSACryptoServiceProvider.cs
- WindowsBrush.cs
- ValidationRuleCollection.cs
- listitem.cs
- QuotedStringWriteStateInfo.cs
- ScrollProperties.cs
- BuildProvidersCompiler.cs
- ListView.cs
- GatewayDefinition.cs
- SoapException.cs
- TableParaClient.cs
- ResourceReferenceKeyNotFoundException.cs
- XmlSchemaObject.cs
- ToolTip.cs
- AssemblySettingAttributes.cs
- SafeNativeMethodsMilCoreApi.cs
- CmsInterop.cs
- CollectionBuilder.cs
- TemplateKeyConverter.cs
- TreeNodeEventArgs.cs
- ReadOnlyDataSource.cs
- PartEditor.cs
- FilePrompt.cs
- C14NUtil.cs
- MetadataSource.cs
- AtomMaterializer.cs
- WebPermission.cs
- TimeSpan.cs
- CommentEmitter.cs
- VisualStyleRenderer.cs
- EDesignUtil.cs
- AvtEvent.cs
- GridViewItemAutomationPeer.cs
- WebControlsSection.cs
- VectorAnimationUsingKeyFrames.cs
- MimeXmlReflector.cs
- BulletedListEventArgs.cs
- DecimalAnimationBase.cs