Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Shared / MS / Internal / Pair.cs / 1 / Pair.cs
//---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // Description: Pair class is useful when one needs to treat a pair of objects as a singly key in a collection. // // // History: // 08/04/2005 : mleonov - Created // //--------------------------------------------------------------------------- using System; using System.Diagnostics; namespace MS.Internal { ////// Pair class is useful when one needs to treat a pair of objects as a singly key in a collection. /// Apart from providing storage and accessors, the class forwards GetHashCode and Equals to the contained objects. /// Both object are allowed to be null. /// internal class Pair { public Pair(object first, object second) { _first = first; _second = second; } public object First { get { return _first; } } public object Second { get { return _second; } } public override int GetHashCode() { return (_first == null ? 0 : _first.GetHashCode()) ^ (_second == null ? 0 : _second.GetHashCode()); } public override bool Equals(object o) { Pair other = o as Pair; return other != null && (_first != null ? _first.Equals(other._first) : other._first == null) && (_second != null ? _second.Equals(other._second) : other._second == null); } private object _first; private object _second; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // Description: Pair class is useful when one needs to treat a pair of objects as a singly key in a collection. // // // History: // 08/04/2005 : mleonov - Created // //--------------------------------------------------------------------------- using System; using System.Diagnostics; namespace MS.Internal { ////// Pair class is useful when one needs to treat a pair of objects as a singly key in a collection. /// Apart from providing storage and accessors, the class forwards GetHashCode and Equals to the contained objects. /// Both object are allowed to be null. /// internal class Pair { public Pair(object first, object second) { _first = first; _second = second; } public object First { get { return _first; } } public object Second { get { return _second; } } public override int GetHashCode() { return (_first == null ? 0 : _first.GetHashCode()) ^ (_second == null ? 0 : _second.GetHashCode()); } public override bool Equals(object o) { Pair other = o as Pair; return other != null && (_first != null ? _first.Equals(other._first) : other._first == null) && (_second != null ? _second.Equals(other._second) : other._second == null); } private object _first; private object _second; } } // 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
- SQLRoleProvider.cs
- SigningCredentials.cs
- StatusBarItemAutomationPeer.cs
- SiteMapNodeCollection.cs
- IconHelper.cs
- TypeConverterAttribute.cs
- BuildProvider.cs
- ListContractAdapter.cs
- ChangeTracker.cs
- PackageFilter.cs
- ArrangedElementCollection.cs
- DataSourceView.cs
- SQLInt64Storage.cs
- DSASignatureDeformatter.cs
- ProxyGenerator.cs
- ToolStripSeparator.cs
- ConditionCollection.cs
- ICspAsymmetricAlgorithm.cs
- CommonRemoteMemoryBlock.cs
- PackWebResponse.cs
- ConvertersCollection.cs
- ChannelFactoryRefCache.cs
- CultureSpecificStringDictionary.cs
- XMLDiffLoader.cs
- AnnotationObservableCollection.cs
- SchemaDeclBase.cs
- DateTimeValueSerializer.cs
- DataGridViewImageCell.cs
- BindingManagerDataErrorEventArgs.cs
- DataContractJsonSerializerOperationFormatter.cs
- ChangePassword.cs
- SoapEnumAttribute.cs
- UserControl.cs
- ViewValidator.cs
- InputMethodStateChangeEventArgs.cs
- CssClassPropertyAttribute.cs
- SecurityManager.cs
- DataMisalignedException.cs
- CompilationSection.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- EventHandlerList.cs
- SafeNativeMethods.cs
- ListSortDescription.cs
- OdbcCommand.cs
- TypeBuilder.cs
- SessionIDManager.cs
- ReferentialConstraint.cs
- TargetParameterCountException.cs
- BitmapEffect.cs
- ExpressionEvaluator.cs
- ImageAttributes.cs
- EFAssociationProvider.cs
- TextChange.cs
- MergeFilterQuery.cs
- ProcessHost.cs
- DynamicDataRoute.cs
- Facet.cs
- DBSchemaTable.cs
- EmptyEnumerable.cs
- DesignColumn.cs
- CompiledXpathExpr.cs
- HttpsChannelFactory.cs
- DetailsViewPageEventArgs.cs
- TextSerializer.cs
- WSHttpBindingBase.cs
- ObjectTag.cs
- InternalBufferOverflowException.cs
- CookielessHelper.cs
- NullRuntimeConfig.cs
- BooleanAnimationBase.cs
- VirtualizingPanel.cs
- ComponentEditorForm.cs
- DBConnection.cs
- TargetInvocationException.cs
- ExpandableObjectConverter.cs
- XmlAttributes.cs
- QilScopedVisitor.cs
- ComponentChangedEvent.cs
- ExpressionParser.cs
- Activation.cs
- DecoderFallbackWithFailureFlag.cs
- PermissionSetTriple.cs
- ClientConfigurationSystem.cs
- MobileTextWriter.cs
- WebPartTransformerAttribute.cs
- peernodestatemanager.cs
- WindowsListViewItemStartMenu.cs
- CoTaskMemSafeHandle.cs
- SkewTransform.cs
- CodeAccessSecurityEngine.cs
- SvcMapFileLoader.cs
- XmlLanguage.cs
- ThicknessAnimation.cs
- ReceiveActivityDesignerTheme.cs
- CombinedHttpChannel.cs
- XXXInfos.cs
- SmiEventStream.cs
- SettingsAttributeDictionary.cs
- TypeExtensionConverter.cs
- GPPOINT.cs