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
- AuthenticationSection.cs
- SHA256Managed.cs
- XslAstAnalyzer.cs
- PropertyToken.cs
- DrawingContextWalker.cs
- WebSysDefaultValueAttribute.cs
- SdlChannelSink.cs
- SafeLibraryHandle.cs
- HttpDictionary.cs
- GenerateTemporaryTargetAssembly.cs
- GridViewColumn.cs
- ContactManager.cs
- GroupDescription.cs
- DodSequenceMerge.cs
- RequiredAttributeAttribute.cs
- SecurityChannelListener.cs
- TreeChangeInfo.cs
- BaseCodePageEncoding.cs
- Annotation.cs
- Typeface.cs
- _TLSstream.cs
- InvariantComparer.cs
- NumberAction.cs
- GridItemProviderWrapper.cs
- MediaPlayerState.cs
- ThreadExceptionDialog.cs
- StatusBarPanelClickEvent.cs
- CreateBookmarkScope.cs
- SHA384Managed.cs
- NgenServicingAttributes.cs
- PerfCounters.cs
- Section.cs
- GridItem.cs
- WmfPlaceableFileHeader.cs
- ReferenceEqualityComparer.cs
- HierarchicalDataSourceControl.cs
- StatusBarPanel.cs
- RichTextBoxAutomationPeer.cs
- InstanceCreationEditor.cs
- ProfilePropertyNameValidator.cs
- RemoteCryptoDecryptRequest.cs
- HtmlWindow.cs
- HideDisabledControlAdapter.cs
- PersianCalendar.cs
- QuotedPrintableStream.cs
- Permission.cs
- DecoderReplacementFallback.cs
- IncrementalReadDecoders.cs
- HtmlMeta.cs
- GeneralTransform3DGroup.cs
- KeyedCollection.cs
- SystemNetworkInterface.cs
- RecommendedAsConfigurableAttribute.cs
- SecurityDocument.cs
- SystemTcpConnection.cs
- XmlWhitespace.cs
- ADMembershipUser.cs
- AppSettingsExpressionBuilder.cs
- UdpUtility.cs
- Ops.cs
- MouseDevice.cs
- OperandQuery.cs
- DynamicResourceExtension.cs
- BitStream.cs
- ContextProperty.cs
- TypeLoadException.cs
- httpstaticobjectscollection.cs
- ClientOptions.cs
- XmlWhitespace.cs
- PrintEvent.cs
- WorkflowControlEndpoint.cs
- AppSettingsSection.cs
- HistoryEventArgs.cs
- RectIndependentAnimationStorage.cs
- ObjectKeyFrameCollection.cs
- ContainerVisual.cs
- ItemCollection.cs
- SoapAttributeAttribute.cs
- UIInitializationException.cs
- StandardBindingOptionalReliableSessionElement.cs
- ForeignKeyConstraint.cs
- UInt32Converter.cs
- TextEffectResolver.cs
- BindStream.cs
- ExpressionSelection.cs
- Drawing.cs
- ValidatingPropertiesEventArgs.cs
- GeometryGroup.cs
- QilTargetType.cs
- BamlRecords.cs
- StateMachineTimers.cs
- BlurBitmapEffect.cs
- SelectionPattern.cs
- VerticalAlignConverter.cs
- RequestCacheEntry.cs
- HttpCookie.cs
- AccessViolationException.cs
- DiscardableAttribute.cs
- Block.cs
- PerspectiveCamera.cs