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
- DropTarget.cs
- ProfileGroupSettingsCollection.cs
- Timer.cs
- Comparer.cs
- TextWriterEngine.cs
- JsonSerializer.cs
- DataGridViewImageColumn.cs
- EntryWrittenEventArgs.cs
- FigureParagraph.cs
- ResolveDuplexCD1AsyncResult.cs
- TypeListConverter.cs
- control.ime.cs
- SegmentInfo.cs
- PropertyMappingExceptionEventArgs.cs
- HttpCapabilitiesEvaluator.cs
- PartialTrustValidationBehavior.cs
- WebResourceAttribute.cs
- ReadOnlyCollectionBuilder.cs
- PublisherMembershipCondition.cs
- PeerNodeAddress.cs
- CommandID.cs
- EmptyStringExpandableObjectConverter.cs
- DataGridHelper.cs
- WebServiceParameterData.cs
- StringUtil.cs
- OTFRasterizer.cs
- StylusButtonEventArgs.cs
- CodeAccessSecurityEngine.cs
- SymbolDocumentGenerator.cs
- AdRotator.cs
- TextPenaltyModule.cs
- TPLETWProvider.cs
- ObjectSet.cs
- IProducerConsumerCollection.cs
- OutputCacheProfileCollection.cs
- ExpressionBindingCollection.cs
- HostSecurityManager.cs
- Image.cs
- FontSourceCollection.cs
- Attributes.cs
- ColorTransformHelper.cs
- ListItemDetailViewAttribute.cs
- CroppedBitmap.cs
- EntityProviderServices.cs
- DataAdapter.cs
- PageCodeDomTreeGenerator.cs
- AsyncPostBackErrorEventArgs.cs
- SafeEventLogWriteHandle.cs
- Journaling.cs
- GridSplitter.cs
- DefaultTextStoreTextComposition.cs
- HttpCachePolicyElement.cs
- TextRangeEditTables.cs
- ManagementException.cs
- ProtocolsConfigurationEntry.cs
- CodeIndexerExpression.cs
- ConfigurationElementCollection.cs
- ServiceBuildProvider.cs
- wgx_render.cs
- ChoiceConverter.cs
- ApplicationId.cs
- X509CertificateValidationMode.cs
- _FixedSizeReader.cs
- PageContentAsyncResult.cs
- RoleExceptions.cs
- TextChange.cs
- SmtpCommands.cs
- CodeGenerationManager.cs
- XmlSchemaParticle.cs
- LinkButton.cs
- AuthenticationManager.cs
- CellConstant.cs
- ResXResourceSet.cs
- StringCollection.cs
- FlowDocumentReaderAutomationPeer.cs
- ReachIDocumentPaginatorSerializerAsync.cs
- GlobalizationSection.cs
- SessionStateItemCollection.cs
- RowSpanVector.cs
- ResourceIDHelper.cs
- GridViewDeletedEventArgs.cs
- XmlComment.cs
- DurableErrorHandler.cs
- _SSPIWrapper.cs
- XmlHierarchyData.cs
- MulticastNotSupportedException.cs
- ExecutionEngineException.cs
- TimeSpanHelper.cs
- GridEntry.cs
- SystemFonts.cs
- FixedTextContainer.cs
- DetailsViewRow.cs
- XmlSchemaSet.cs
- PointLight.cs
- MeasureItemEvent.cs
- OperatorExpressions.cs
- LayoutInformation.cs
- CultureInfoConverter.cs
- SimpleRecyclingCache.cs
- ArrowControl.xaml.cs