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
- SymbolMethod.cs
- Button.cs
- CalendarDateRangeChangingEventArgs.cs
- DetailsViewRowCollection.cs
- EdmError.cs
- TreeNodeStyleCollection.cs
- BinaryObjectReader.cs
- TextEditorSpelling.cs
- ObjectListItemCollection.cs
- MemberAccessException.cs
- TransactionManager.cs
- Wizard.cs
- StyleSheetComponentEditor.cs
- SourceChangedEventArgs.cs
- DetailsViewRowCollection.cs
- TypeExtensionConverter.cs
- Geometry.cs
- TemplatedMailWebEventProvider.cs
- BuildProvider.cs
- CatalogPart.cs
- DataGridViewHitTestInfo.cs
- WorkflowInstance.cs
- NetStream.cs
- InvokePatternIdentifiers.cs
- SQLInt32Storage.cs
- CodeDirectiveCollection.cs
- __Filters.cs
- BitmapImage.cs
- ImageInfo.cs
- SrgsRule.cs
- SoapMessage.cs
- Evaluator.cs
- DataBinding.cs
- TextModifierScope.cs
- WorkflowLayouts.cs
- ZipIOLocalFileBlock.cs
- ObjectToken.cs
- XmlRawWriter.cs
- DataObject.cs
- Graphics.cs
- PermissionSetEnumerator.cs
- DataGridViewRowsAddedEventArgs.cs
- WorkflowRuntimeEndpoint.cs
- PrimitiveType.cs
- Metadata.cs
- TreeNodeSelectionProcessor.cs
- ReversePositionQuery.cs
- WpfGeneratedKnownTypes.cs
- RepeaterItem.cs
- RequestDescription.cs
- WorkflowOperationContext.cs
- ListViewTableRow.cs
- RenderDataDrawingContext.cs
- COM2PictureConverter.cs
- CompareInfo.cs
- BridgeDataReader.cs
- OleDbFactory.cs
- Convert.cs
- WinInetCache.cs
- GenericIdentity.cs
- SubpageParaClient.cs
- AdornedElementPlaceholder.cs
- SoapSchemaImporter.cs
- ContentIterators.cs
- TableProvider.cs
- HashAlgorithm.cs
- SelectedDatesCollection.cs
- SourceFileBuildProvider.cs
- ProfessionalColors.cs
- Crypto.cs
- HttpWriter.cs
- RMPublishingDialog.cs
- FilteredXmlReader.cs
- ConfigXmlComment.cs
- XmlHelper.cs
- AlphaSortedEnumConverter.cs
- AsymmetricKeyExchangeFormatter.cs
- ListViewInsertEventArgs.cs
- ChannelManager.cs
- WebPartsSection.cs
- DesignerUtils.cs
- BorderGapMaskConverter.cs
- XmlDataSourceView.cs
- FlatButtonAppearance.cs
- MobileContainerDesigner.cs
- DateRangeEvent.cs
- SQLStringStorage.cs
- BeginStoryboard.cs
- ContextMenu.cs
- ButtonStandardAdapter.cs
- TextTreeUndo.cs
- PipelineDeploymentState.cs
- UInt64Storage.cs
- StylusPlugin.cs
- UdpReplyToBehavior.cs
- SQLGuid.cs
- TextTreeRootTextBlock.cs
- DataGridCaption.cs
- Calendar.cs
- EventLogPermissionEntry.cs