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
- ListChunk.cs
- SessionPageStateSection.cs
- RoutedEvent.cs
- Thread.cs
- InertiaRotationBehavior.cs
- ChildDocumentBlock.cs
- Visual.cs
- HwndSubclass.cs
- XmlSchemaSimpleContentExtension.cs
- ParseHttpDate.cs
- AutoGeneratedField.cs
- FixUp.cs
- VectorAnimationBase.cs
- AccessibleObject.cs
- UnsafeCollabNativeMethods.cs
- UserControlParser.cs
- SessionIDManager.cs
- UrlAuthFailedErrorFormatter.cs
- ContextMenuAutomationPeer.cs
- _ListenerAsyncResult.cs
- SqlNode.cs
- DaylightTime.cs
- CollectionType.cs
- TypeSource.cs
- SspiNegotiationTokenProvider.cs
- TextUtf8RawTextWriter.cs
- SEHException.cs
- MiniAssembly.cs
- PointUtil.cs
- XmlReflectionImporter.cs
- RefreshEventArgs.cs
- XmlReader.cs
- SplineKeyFrames.cs
- ImageMapEventArgs.cs
- DataErrorValidationRule.cs
- PermissionSetEnumerator.cs
- ReferenceEqualityComparer.cs
- DataGridViewSelectedCellCollection.cs
- SharedStream.cs
- BaseHashHelper.cs
- QilGenerator.cs
- CharacterHit.cs
- ReadOnlyHierarchicalDataSourceView.cs
- MessageFormatterConverter.cs
- SQLInt16Storage.cs
- StructuredProperty.cs
- sqlcontext.cs
- CodeAttributeDeclarationCollection.cs
- TrackingSection.cs
- PersistenceTask.cs
- ShapeTypeface.cs
- XmlReaderSettings.cs
- SqlMethodTransformer.cs
- EmbossBitmapEffect.cs
- TextDpi.cs
- StreamWithDictionary.cs
- WorkflowEnvironment.cs
- ConfigXmlSignificantWhitespace.cs
- PageCodeDomTreeGenerator.cs
- XmlElementAttributes.cs
- StylusPointDescription.cs
- IPEndPoint.cs
- MenuAdapter.cs
- TaskScheduler.cs
- RuntimeResourceSet.cs
- Soap11ServerProtocol.cs
- DropDownHolder.cs
- MonthCalendar.cs
- ToolStripDropDownClosingEventArgs.cs
- DynamicRouteExpression.cs
- TypeUnloadedException.cs
- WasHostedComPlusFactory.cs
- Image.cs
- NetNamedPipeSecurity.cs
- HtmlUtf8RawTextWriter.cs
- UnsignedPublishLicense.cs
- SerializationSectionGroup.cs
- COM2PropertyDescriptor.cs
- ErrorWebPart.cs
- Win32SafeHandles.cs
- BmpBitmapDecoder.cs
- PersonalizationStateInfoCollection.cs
- XmlSchemaSimpleTypeRestriction.cs
- PenContext.cs
- SvcMapFile.cs
- RowTypeElement.cs
- Table.cs
- Parameter.cs
- InvalidProgramException.cs
- ClientSettingsSection.cs
- TemplateInstanceAttribute.cs
- ObjectQueryProvider.cs
- TripleDESCryptoServiceProvider.cs
- HeaderUtility.cs
- CustomError.cs
- EditorZoneBase.cs
- BitmapEffectDrawingContextWalker.cs
- CollectionTypeElement.cs
- SafeReversePInvokeHandle.cs
- EventLogEntryCollection.cs