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
- BooleanToSelectiveScrollingOrientationConverter.cs
- OracleMonthSpan.cs
- CombinedGeometry.cs
- CalculatedColumn.cs
- TransformCryptoHandle.cs
- Base64Stream.cs
- WhitespaceRule.cs
- QueryCacheManager.cs
- Int32CollectionValueSerializer.cs
- AxisAngleRotation3D.cs
- TextTreeObjectNode.cs
- HeaderPanel.cs
- XmlUnspecifiedAttribute.cs
- HwndProxyElementProvider.cs
- GlobalItem.cs
- UnsafeNativeMethods.cs
- GeometryModel3D.cs
- DataGridTextBoxColumn.cs
- BamlRecords.cs
- AsyncDataRequest.cs
- ServiceChannelFactory.cs
- TableCell.cs
- WebPartConnectionsConnectVerb.cs
- BitmapEffectGroup.cs
- FrameworkElementFactory.cs
- LockedAssemblyCache.cs
- BitConverter.cs
- _BufferOffsetSize.cs
- _SSPISessionCache.cs
- CodeDelegateInvokeExpression.cs
- EncoderBestFitFallback.cs
- ModelFunctionTypeElement.cs
- LocalizabilityAttribute.cs
- XamlBrushSerializer.cs
- BasicViewGenerator.cs
- FormatVersion.cs
- WebPartDeleteVerb.cs
- CatalogPartCollection.cs
- diagnosticsswitches.cs
- AutomationIdentifier.cs
- FrameworkElementAutomationPeer.cs
- _LocalDataStore.cs
- PropertyDescriptorCollection.cs
- XamlTemplateSerializer.cs
- InternalConfigSettingsFactory.cs
- MessageBox.cs
- StandardBindingOptionalReliableSessionElement.cs
- ScriptReferenceEventArgs.cs
- Tile.cs
- PartialTrustHelpers.cs
- SerializerProvider.cs
- TypedTableBaseExtensions.cs
- Stack.cs
- LocalServiceSecuritySettingsElement.cs
- ResourceDescriptionAttribute.cs
- OperandQuery.cs
- TextUtf8RawTextWriter.cs
- RawContentTypeMapper.cs
- PageParserFilter.cs
- TokenBasedSetEnumerator.cs
- BitmapSource.cs
- SeekStoryboard.cs
- OutOfMemoryException.cs
- DataSourceXmlElementAttribute.cs
- mongolianshape.cs
- KnownBoxes.cs
- AssemblySettingAttributes.cs
- GridViewDeleteEventArgs.cs
- EntityUtil.cs
- _ProxyRegBlob.cs
- SiteMapDataSource.cs
- DurableOperationAttribute.cs
- TextParagraph.cs
- GroupQuery.cs
- ResourcesBuildProvider.cs
- UnsafeNativeMethods.cs
- Binding.cs
- KeyedQueue.cs
- NameValueConfigurationElement.cs
- ProviderCollection.cs
- ConnectionStringSettings.cs
- Vector3DCollectionConverter.cs
- CatalogZone.cs
- ConfigurationCollectionAttribute.cs
- StrokeDescriptor.cs
- PropertyTabChangedEvent.cs
- EncoderParameter.cs
- PropertyGeneratedEventArgs.cs
- CancelEventArgs.cs
- ExecutionEngineException.cs
- RegistryConfigurationProvider.cs
- ProxyWebPartManager.cs
- FontDifferentiator.cs
- SendMailErrorEventArgs.cs
- AppDomainFactory.cs
- GeometryHitTestResult.cs
- XmlSerializationReader.cs
- SmtpNegotiateAuthenticationModule.cs
- Material.cs
- CloudCollection.cs