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
- errorpatternmatcher.cs
- XmlQueryOutput.cs
- SystemInfo.cs
- GridViewSortEventArgs.cs
- RequestReplyCorrelator.cs
- MenuTracker.cs
- TdsParserStaticMethods.cs
- HttpListenerTimeoutManager.cs
- DiscreteKeyFrames.cs
- NotifyParentPropertyAttribute.cs
- ProgressPage.cs
- ScrollableControl.cs
- DataGridParentRows.cs
- ControlUtil.cs
- Application.cs
- XmlSchemaObjectCollection.cs
- LambdaCompiler.Statements.cs
- GroupBoxRenderer.cs
- StylusPointPropertyUnit.cs
- DeleteBookmarkScope.cs
- ContractReference.cs
- ComplexBindingPropertiesAttribute.cs
- EmptyQuery.cs
- Label.cs
- ResXFileRef.cs
- ObjectDataSourceWizardForm.cs
- SignatureGenerator.cs
- BookmarkUndoUnit.cs
- UIElement.cs
- CqlLexer.cs
- WebPartManager.cs
- PrintEvent.cs
- InputLanguageCollection.cs
- CodeGroup.cs
- WebPartCloseVerb.cs
- AstNode.cs
- ApplicationActivator.cs
- PageAsyncTaskManager.cs
- CodeThrowExceptionStatement.cs
- ProgressBar.cs
- WindowsFormsSectionHandler.cs
- DataGridViewCheckBoxCell.cs
- VariableQuery.cs
- EventDescriptorCollection.cs
- SelectionPatternIdentifiers.cs
- DropDownList.cs
- LinkUtilities.cs
- Matrix3D.cs
- CommandLibraryHelper.cs
- AutoSizeComboBox.cs
- EventRoute.cs
- TileModeValidation.cs
- wgx_commands.cs
- BooleanToVisibilityConverter.cs
- CodeLinePragma.cs
- InternalBase.cs
- SchemaComplexType.cs
- CapabilitiesState.cs
- AppDomainResourcePerfCounters.cs
- ActivityCodeGenerator.cs
- TransactionFilter.cs
- XmlDataSourceNodeDescriptor.cs
- SpeechEvent.cs
- SqlDataSourceView.cs
- SymmetricAlgorithm.cs
- MemoryRecordBuffer.cs
- InkCanvas.cs
- Crc32Helper.cs
- PropertyChangeTracker.cs
- EditorPart.cs
- NativeMethods.cs
- ControllableStoryboardAction.cs
- XamlVector3DCollectionSerializer.cs
- EraserBehavior.cs
- RuntimeVariableList.cs
- SiteIdentityPermission.cs
- Rect3D.cs
- GridViewCellAutomationPeer.cs
- BamlResourceSerializer.cs
- SecurityRuntime.cs
- Effect.cs
- TemplateControlCodeDomTreeGenerator.cs
- HiddenField.cs
- PlanCompilerUtil.cs
- UserUseLicenseDictionaryLoader.cs
- DtdParser.cs
- AnnouncementSendsAsyncResult.cs
- SecurityElement.cs
- RadialGradientBrush.cs
- TemplateApplicationHelper.cs
- UdpMessageProperty.cs
- HexParser.cs
- RsaSecurityKey.cs
- Animatable.cs
- Debug.cs
- ProviderException.cs
- TypeSemantics.cs
- Panel.cs
- WebPartsPersonalization.cs
- ConnectionProviderAttribute.cs