Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Internal / Pair.cs / 1305600 / 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
- SliderAutomationPeer.cs
- SqlBuffer.cs
- XmlSchemaParticle.cs
- DrawingBrush.cs
- TaskFormBase.cs
- ClusterRegistryConfigurationProvider.cs
- RootNamespaceAttribute.cs
- BindingManagerDataErrorEventArgs.cs
- CodeDirectiveCollection.cs
- AsyncOperationManager.cs
- StrokeDescriptor.cs
- InfoCardRSAPKCS1SignatureDeformatter.cs
- TileModeValidation.cs
- UnauthorizedWebPart.cs
- OleDbWrapper.cs
- HtmlFormParameterReader.cs
- XslAstAnalyzer.cs
- OSEnvironmentHelper.cs
- NavigationCommands.cs
- DiagnosticsConfigurationHandler.cs
- SatelliteContractVersionAttribute.cs
- SharedPerformanceCounter.cs
- ParallelEnumerable.cs
- XmlSerializerSection.cs
- ServiceManager.cs
- sqlpipe.cs
- XmlSchema.cs
- DataSourceControl.cs
- PeerObject.cs
- ReaderWriterLockWrapper.cs
- SourceFilter.cs
- ObjectConverter.cs
- HGlobalSafeHandle.cs
- StickyNoteHelper.cs
- UnsafeNetInfoNativeMethods.cs
- BinaryUtilClasses.cs
- StringUtil.cs
- NetMsmqBinding.cs
- Expressions.cs
- ServiceModelConfigurationSectionGroup.cs
- TimeStampChecker.cs
- PermissionToken.cs
- InstanceContext.cs
- ToolStripHighContrastRenderer.cs
- SHA1CryptoServiceProvider.cs
- IPEndPoint.cs
- GAC.cs
- MonitoringDescriptionAttribute.cs
- ExpressionBindings.cs
- XPathMultyIterator.cs
- StylusTip.cs
- BitmapFrameEncode.cs
- XslAst.cs
- QueryCursorEventArgs.cs
- DataGridViewCellEventArgs.cs
- TemplateKey.cs
- FolderLevelBuildProviderCollection.cs
- DesignerUtility.cs
- SoapAttributeOverrides.cs
- EnumUnknown.cs
- Comparer.cs
- InternalControlCollection.cs
- TextEditorParagraphs.cs
- RecognizerBase.cs
- MenuAutomationPeer.cs
- LeafCellTreeNode.cs
- SourceItem.cs
- ReliableChannelFactory.cs
- SessionIDManager.cs
- IsolatedStorageException.cs
- CursorEditor.cs
- PhysicalAddress.cs
- NavigatorInput.cs
- ReachSerializationUtils.cs
- HtmlPanelAdapter.cs
- MenuItemStyleCollection.cs
- ScalarType.cs
- SubclassTypeValidator.cs
- CompilationUnit.cs
- RSAOAEPKeyExchangeDeformatter.cs
- RelationshipConverter.cs
- RemoteWebConfigurationHostServer.cs
- CryptoApi.cs
- CompilationLock.cs
- DSACryptoServiceProvider.cs
- HandlerBase.cs
- SchemaImporter.cs
- ClientRoleProvider.cs
- ChildDocumentBlock.cs
- HyperLinkStyle.cs
- SplashScreenNativeMethods.cs
- PanelDesigner.cs
- SqlInternalConnectionTds.cs
- DbConnectionStringBuilder.cs
- XmlAttributeCollection.cs
- DbProviderFactory.cs
- ClientViaElement.cs
- GenerateTemporaryTargetAssembly.cs
- EventSinkHelperWriter.cs
- ArgumentDesigner.xaml.cs