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
- ReflectionPermission.cs
- DatagridviewDisplayedBandsData.cs
- ParseChildrenAsPropertiesAttribute.cs
- DataGridView.cs
- Stack.cs
- DbQueryCommandTree.cs
- Vector3DCollectionValueSerializer.cs
- TreeNode.cs
- HttpPostProtocolReflector.cs
- ByteStreamMessageEncoder.cs
- QilReplaceVisitor.cs
- HealthMonitoringSectionHelper.cs
- CompilerTypeWithParams.cs
- ConfigurationStrings.cs
- WebPartDisplayModeCollection.cs
- _SSPIWrapper.cs
- TemplateControlCodeDomTreeGenerator.cs
- ConfigurationException.cs
- EmbossBitmapEffect.cs
- RelativeSource.cs
- DataGridViewCellStyleBuilderDialog.cs
- RestHandler.cs
- StateFinalizationActivity.cs
- ThrowOnMultipleAssignment.cs
- MessageBodyMemberAttribute.cs
- DecimalAnimation.cs
- SessionEndingCancelEventArgs.cs
- SpellerError.cs
- connectionpool.cs
- DependencyPropertyHelper.cs
- CharacterString.cs
- Model3DCollection.cs
- LocatorPartList.cs
- PanelStyle.cs
- ComplexType.cs
- EdmProviderManifest.cs
- X509CertificateClaimSet.cs
- TypeBuilder.cs
- DataGridViewRowPrePaintEventArgs.cs
- SecurityPolicySection.cs
- BamlBinaryReader.cs
- OleDbCommand.cs
- ProtocolViolationException.cs
- MetadataPropertyCollection.cs
- NotFiniteNumberException.cs
- OutputCacheModule.cs
- OdbcInfoMessageEvent.cs
- StrokeDescriptor.cs
- SubpageParagraph.cs
- UrlMappingsSection.cs
- _OverlappedAsyncResult.cs
- ChoiceConverter.cs
- ColumnResizeAdorner.cs
- PixelFormats.cs
- ValidateNames.cs
- DataTemplateKey.cs
- ConfigurationValue.cs
- TransformerInfoCollection.cs
- SoapCommonClasses.cs
- SerializationStore.cs
- FastEncoderWindow.cs
- ClientTargetCollection.cs
- Comparer.cs
- ApplicationBuildProvider.cs
- TransactionTraceIdentifier.cs
- VerticalAlignConverter.cs
- UpDownEvent.cs
- ServiceAuthorizationBehavior.cs
- MachineKeyConverter.cs
- StaticSiteMapProvider.cs
- MailAddressCollection.cs
- XmlSchemaSimpleContentExtension.cs
- ArrayListCollectionBase.cs
- AlternationConverter.cs
- DateTimeParse.cs
- HtmlTable.cs
- DispatchWrapper.cs
- DesignerDataSourceView.cs
- XmlException.cs
- CustomTrackingRecord.cs
- ProfileSection.cs
- WindowsClientCredential.cs
- DispatcherFrame.cs
- WebControlsSection.cs
- DateTimeFormatInfoScanner.cs
- ProgressBar.cs
- ApplicationSettingsBase.cs
- AddInControllerImpl.cs
- WindowsBrush.cs
- XMLSchema.cs
- LayoutEngine.cs
- JapaneseCalendar.cs
- VirtualPathProvider.cs
- TimeBoundedCache.cs
- ACE.cs
- metadatamappinghashervisitor.cs
- RIPEMD160Managed.cs
- SecurityManager.cs
- PassportAuthenticationEventArgs.cs
- ErrorFormatterPage.cs