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
- CalendarModeChangedEventArgs.cs
- FixedPageProcessor.cs
- BindingMAnagerBase.cs
- EntityProviderFactory.cs
- AuthenticationModuleElementCollection.cs
- DynamicDocumentPaginator.cs
- ZipPackage.cs
- BindingNavigator.cs
- ServiceDescription.cs
- HScrollBar.cs
- VisualTreeUtils.cs
- ProcessThread.cs
- KeySpline.cs
- LookupNode.cs
- TreeViewDataItemAutomationPeer.cs
- ImpersonationContext.cs
- EntityDataSourceContextDisposingEventArgs.cs
- InternalCache.cs
- ObjectListCommandsPage.cs
- EditorPartCollection.cs
- ProviderBase.cs
- ConnectionInterfaceCollection.cs
- AutomationPropertyInfo.cs
- BitmapEffectInput.cs
- StreamDocument.cs
- StringUtil.cs
- HMACSHA256.cs
- BufferedGraphicsContext.cs
- FileEnumerator.cs
- ViewSimplifier.cs
- DataKey.cs
- NativeMethods.cs
- CommandManager.cs
- ToolTipAutomationPeer.cs
- VisualStateChangedEventArgs.cs
- DataService.cs
- ExpanderAutomationPeer.cs
- SystemIPv4InterfaceProperties.cs
- SerializationUtility.cs
- EventlogProvider.cs
- UICuesEvent.cs
- ContentTextAutomationPeer.cs
- Deserializer.cs
- AlphabeticalEnumConverter.cs
- AbandonedMutexException.cs
- SynchronizationLockException.cs
- RegisteredScript.cs
- DebugHandleTracker.cs
- DeobfuscatingStream.cs
- BasicCellRelation.cs
- XmlSchemaComplexContentExtension.cs
- CompiledIdentityConstraint.cs
- InvalidProgramException.cs
- TraceLevelStore.cs
- String.cs
- ButtonField.cs
- ExpressionWriter.cs
- HttpRawResponse.cs
- RtfControls.cs
- InstanceOwnerQueryResult.cs
- XmlSerializableWriter.cs
- UIPropertyMetadata.cs
- SqlInternalConnection.cs
- ProcessHostMapPath.cs
- SamlSerializer.cs
- UnknownWrapper.cs
- IPPacketInformation.cs
- BrowserTree.cs
- MgmtConfigurationRecord.cs
- OdbcUtils.cs
- AdjustableArrowCap.cs
- SafeRightsManagementQueryHandle.cs
- BitmapPalettes.cs
- BitmapEffectGeneralTransform.cs
- TextureBrush.cs
- ArrayConverter.cs
- ElementAction.cs
- AssemblyFilter.cs
- Win32SafeHandles.cs
- SqlRewriteScalarSubqueries.cs
- RadioButtonBaseAdapter.cs
- FixUpCollection.cs
- AnimationTimeline.cs
- DataException.cs
- AddIn.cs
- InvalidWMPVersionException.cs
- ClassHandlersStore.cs
- TypeConstant.cs
- DataGridViewCellCollection.cs
- Facet.cs
- DetailsViewUpdatedEventArgs.cs
- ServiceOperationWrapper.cs
- MenuCommands.cs
- GradientStopCollection.cs
- AuthenticatedStream.cs
- PageEventArgs.cs
- Symbol.cs
- FrameworkElement.cs
- BamlMapTable.cs
- DisplayMemberTemplateSelector.cs