Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- HeaderElement.cs
- TreeViewAutomationPeer.cs
- formatter.cs
- LazyTextWriterCreator.cs
- RoleGroupCollection.cs
- ExpressionEvaluator.cs
- SkewTransform.cs
- Int16AnimationBase.cs
- PolicyFactory.cs
- VirtualDirectoryMapping.cs
- Point3DAnimationUsingKeyFrames.cs
- DecimalAnimationUsingKeyFrames.cs
- OneWayBindingElementImporter.cs
- Int16AnimationBase.cs
- SqlInfoMessageEvent.cs
- HtmlTableRow.cs
- TransformGroup.cs
- FatalException.cs
- SpellerError.cs
- SimpleType.cs
- InstanceDescriptor.cs
- ComboBoxRenderer.cs
- MethodCallExpression.cs
- CriticalExceptions.cs
- recordstate.cs
- RoleGroup.cs
- VarInfo.cs
- AsymmetricSignatureFormatter.cs
- InputElement.cs
- NameValuePermission.cs
- WindowsAuthenticationEventArgs.cs
- CopyOnWriteList.cs
- TimeZone.cs
- HtmlEncodedRawTextWriter.cs
- IBuiltInEvidence.cs
- MailMessage.cs
- HttpRequest.cs
- AdornerHitTestResult.cs
- BinaryMethodMessage.cs
- StylusPointDescription.cs
- CancellationScope.cs
- WsatConfiguration.cs
- pingexception.cs
- DataGridHeaderBorder.cs
- MarkupObject.cs
- FrameworkTextComposition.cs
- LocatorPart.cs
- XpsS0ValidatingLoader.cs
- ThreadSafeMessageFilterTable.cs
- ExpressionVisitorHelpers.cs
- userdatakeys.cs
- BitmapDecoder.cs
- CustomWebEventKey.cs
- LinqDataSourceStatusEventArgs.cs
- DescendantBaseQuery.cs
- SchemaNames.cs
- TextMetrics.cs
- SemanticAnalyzer.cs
- ServiceAppDomainAssociationProvider.cs
- PointCollectionConverter.cs
- BinHexDecoder.cs
- ColumnHeader.cs
- StringSorter.cs
- CompositeActivityTypeDescriptor.cs
- GZipStream.cs
- _ListenerResponseStream.cs
- EventDriven.cs
- IconEditor.cs
- BaseDataListPage.cs
- ImageSourceValueSerializer.cs
- SignedXml.cs
- RuleAttributes.cs
- TypeHelpers.cs
- HotSpot.cs
- ConfigurationManagerInternalFactory.cs
- SecurityChannel.cs
- DefaultObjectMappingItemCollection.cs
- CellLabel.cs
- unitconverter.cs
- MailFileEditor.cs
- DocumentOrderComparer.cs
- Composition.cs
- CapabilitiesPattern.cs
- AttachmentService.cs
- WinFormsSecurity.cs
- DefaultValueTypeConverter.cs
- DataGridColumnHeadersPresenter.cs
- TreeWalker.cs
- PanelStyle.cs
- SubMenuStyle.cs
- DataTablePropertyDescriptor.cs
- RuntimeHelpers.cs
- AxisAngleRotation3D.cs
- SafeRegistryKey.cs
- DataGridPageChangedEventArgs.cs
- SqlCacheDependencyDatabaseCollection.cs
- NavigationPropertyEmitter.cs
- indexingfiltermarshaler.cs
- EmptyEnumerable.cs
- PasswordBox.cs