Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- HScrollBar.cs
- CanExecuteRoutedEventArgs.cs
- XmlCharType.cs
- DataGridAutomationPeer.cs
- SerializationAttributes.cs
- BlobPersonalizationState.cs
- WaitForChangedResult.cs
- OutputCache.cs
- SqlTypesSchemaImporter.cs
- Menu.cs
- EntityDataSourceStatementEditor.cs
- KeyValuePair.cs
- safex509handles.cs
- UntrustedRecipientException.cs
- RectangleGeometry.cs
- SessionEndingCancelEventArgs.cs
- WebPermission.cs
- DesignerActionItemCollection.cs
- SemanticAnalyzer.cs
- DataGridItemEventArgs.cs
- EventSource.cs
- TypeReference.cs
- XmlLinkedNode.cs
- _NegoStream.cs
- File.cs
- SqlClientPermission.cs
- PropertyInformationCollection.cs
- Underline.cs
- GlobalizationAssembly.cs
- DataStorage.cs
- RoutingEndpointTrait.cs
- CapiSafeHandles.cs
- SpAudioStreamWrapper.cs
- Vector3DConverter.cs
- ComboBoxRenderer.cs
- DiscreteKeyFrames.cs
- RoutedEventArgs.cs
- Update.cs
- EmbeddedMailObject.cs
- DataSet.cs
- Assert.cs
- HwndTarget.cs
- ProcessProtocolHandler.cs
- DateTimeOffsetConverter.cs
- BezierSegment.cs
- WebServiceParameterData.cs
- DataSpaceManager.cs
- ComponentFactoryHelpers.cs
- WorkflowQueue.cs
- SystemFonts.cs
- BackgroundFormatInfo.cs
- BamlTreeMap.cs
- BridgeDataReader.cs
- FileSecurity.cs
- PopupEventArgs.cs
- ServiceThrottle.cs
- StreamInfo.cs
- ToggleButtonAutomationPeer.cs
- SizeConverter.cs
- DropTarget.cs
- AnnotationResourceChangedEventArgs.cs
- ZipIOLocalFileHeader.cs
- WebPartDescription.cs
- Symbol.cs
- DataRow.cs
- XmlValueConverter.cs
- XmlDataCollection.cs
- XamlHttpHandlerFactory.cs
- DesignParameter.cs
- Baml6ConstructorInfo.cs
- MetricEntry.cs
- DataException.cs
- ObjectPropertyMapping.cs
- MailAddressCollection.cs
- ModuleConfigurationInfo.cs
- DbConnectionHelper.cs
- DynamicRenderer.cs
- SiteMapSection.cs
- WinFormsUtils.cs
- DataColumnMapping.cs
- FrameworkContentElement.cs
- Int32KeyFrameCollection.cs
- CompositeScriptReference.cs
- FixedHighlight.cs
- SqlMethodTransformer.cs
- ServerType.cs
- PrincipalPermission.cs
- ProfilePropertySettingsCollection.cs
- datacache.cs
- Pkcs9Attribute.cs
- EncoderParameters.cs
- OpenFileDialog.cs
- LassoHelper.cs
- OletxTransactionHeader.cs
- MouseCaptureWithinProperty.cs
- ProviderManager.cs
- AppDomainFactory.cs
- GroupQuery.cs
- InputScope.cs
- CornerRadiusConverter.cs