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
- RegexMatchCollection.cs
- DataListItem.cs
- PingReply.cs
- CharEntityEncoderFallback.cs
- RegexGroup.cs
- DbConnectionClosed.cs
- HighlightComponent.cs
- Base64Encoding.cs
- IteratorFilter.cs
- BufferedReceiveElement.cs
- TypeConverterHelper.cs
- StdValidatorsAndConverters.cs
- Sorting.cs
- InputLanguage.cs
- GeometryDrawing.cs
- WindowsFormsHelpers.cs
- DataGridViewImageColumn.cs
- Expressions.cs
- DataBindingExpressionBuilder.cs
- SafeViewOfFileHandle.cs
- EmptyQuery.cs
- ClipboardProcessor.cs
- RunClient.cs
- XamlSerializerUtil.cs
- SpeechSynthesizer.cs
- XmlAttributeCache.cs
- SystemIPv4InterfaceProperties.cs
- DesignerDataTable.cs
- HwndHostAutomationPeer.cs
- OperationGenerator.cs
- XPathMultyIterator.cs
- HttpListenerContext.cs
- WorkerRequest.cs
- SoapTypeAttribute.cs
- ContainerControl.cs
- GroupBox.cs
- QueryAccessibilityHelpEvent.cs
- ObjectViewEntityCollectionData.cs
- ViewManager.cs
- EncoderParameter.cs
- XmlNavigatorFilter.cs
- _AuthenticationState.cs
- CompatibleIComparer.cs
- FixUp.cs
- ObjectSelectorEditor.cs
- DefaultCommandExtensionCallback.cs
- OciEnlistContext.cs
- SingleResultAttribute.cs
- XmlCustomFormatter.cs
- ClearTypeHintValidation.cs
- InheritanceContextHelper.cs
- ResourceReferenceKeyNotFoundException.cs
- PerformanceCounter.cs
- bindurihelper.cs
- Hex.cs
- hwndwrapper.cs
- AnnotationObservableCollection.cs
- ExtensionSurface.cs
- SafePointer.cs
- SessionSwitchEventArgs.cs
- DataGridViewCellFormattingEventArgs.cs
- DefaultBindingPropertyAttribute.cs
- CloudCollection.cs
- SqlClientMetaDataCollectionNames.cs
- AppSettingsSection.cs
- XmlAnyAttributeAttribute.cs
- RightsManagementUser.cs
- JsonDeserializer.cs
- LoginName.cs
- ObjectList.cs
- ClientTargetSection.cs
- FormsAuthenticationUser.cs
- ConfigurationCollectionAttribute.cs
- BindingManagerDataErrorEventArgs.cs
- WebRequestModuleElementCollection.cs
- WsrmFault.cs
- ResetableIterator.cs
- Type.cs
- ScriptRegistrationManager.cs
- ConfigXmlWhitespace.cs
- InplaceBitmapMetadataWriter.cs
- DesignTimeParseData.cs
- DeclarativeExpressionConditionDeclaration.cs
- ManipulationCompletedEventArgs.cs
- XamlTypeMapper.cs
- DeleteBookmarkScope.cs
- GroupStyle.cs
- TagMapInfo.cs
- EncryptedPackageFilter.cs
- ClientFactory.cs
- SwitchAttribute.cs
- Object.cs
- DataGridViewLinkColumn.cs
- TemplateEditingFrame.cs
- ScalarRestriction.cs
- RtfNavigator.cs
- DesignTimeTemplateParser.cs
- GenericsInstances.cs
- QuotaThrottle.cs
- XmlElement.cs