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
- IntPtr.cs
- HtmlTitle.cs
- PagePropertiesChangingEventArgs.cs
- CodeNamespace.cs
- TypeElement.cs
- ClientScriptItemCollection.cs
- rsa.cs
- MetaModel.cs
- SineEase.cs
- XmlNamespaceMappingCollection.cs
- AbstractSvcMapFileLoader.cs
- UpDownBaseDesigner.cs
- NativeCppClassAttribute.cs
- AnnotationStore.cs
- sortedlist.cs
- DelayedRegex.cs
- ScalarOps.cs
- WebControl.cs
- WaveHeader.cs
- DataConnectionHelper.cs
- LongTypeConverter.cs
- _TransmitFileOverlappedAsyncResult.cs
- CommonGetThemePartSize.cs
- BindingBase.cs
- Size3DConverter.cs
- OpenTypeMethods.cs
- BamlLocalizableResource.cs
- PointLight.cs
- SchemaElementLookUpTableEnumerator.cs
- XmlSchemaObject.cs
- CodeIdentifier.cs
- WindowAutomationPeer.cs
- XamlGridLengthSerializer.cs
- DeferredRunTextReference.cs
- MarkedHighlightComponent.cs
- XmlNode.cs
- DataGridPageChangedEventArgs.cs
- ResourcePropertyMemberCodeDomSerializer.cs
- TraceSection.cs
- FrameSecurityDescriptor.cs
- RedBlackList.cs
- SinglePageViewer.cs
- GZipDecoder.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- OdbcHandle.cs
- NetworkCredential.cs
- FileCodeGroup.cs
- RootProfilePropertySettingsCollection.cs
- TextElementCollectionHelper.cs
- TextAction.cs
- StackOverflowException.cs
- SharedStatics.cs
- XmlSerializationWriter.cs
- XXXOnTypeBuilderInstantiation.cs
- ActionItem.cs
- GroupStyle.cs
- Container.cs
- Help.cs
- TextEndOfParagraph.cs
- RadioButtonStandardAdapter.cs
- SQLUtility.cs
- InProcStateClientManager.cs
- BrowserCapabilitiesFactory.cs
- FrameworkReadOnlyPropertyMetadata.cs
- AssociationSetEnd.cs
- DeclarativeCatalogPart.cs
- DataBoundControlHelper.cs
- FrameworkElement.cs
- TraceShell.cs
- AuthenticationException.cs
- PageAsyncTask.cs
- ETagAttribute.cs
- FixedElement.cs
- ADMembershipProvider.cs
- HttpPostedFile.cs
- XamlClipboardData.cs
- DesignerObjectListAdapter.cs
- TdsParserStateObject.cs
- BindingEntityInfo.cs
- RowToParametersTransformer.cs
- TableHeaderCell.cs
- SimpleWebHandlerParser.cs
- FontStyle.cs
- EventMappingSettings.cs
- NumericUpDownAccelerationCollection.cs
- InkCanvasSelectionAdorner.cs
- SafeLibraryHandle.cs
- StaticFileHandler.cs
- RepeaterItemEventArgs.cs
- EdmRelationshipRoleAttribute.cs
- CodeGeneratorOptions.cs
- ReadOnlyPropertyMetadata.cs
- RepeatInfo.cs
- ProtectedConfigurationProviderCollection.cs
- JpegBitmapDecoder.cs
- ContentElement.cs
- mediaclock.cs
- KeyedPriorityQueue.cs
- TypeSystem.cs
- AssemblyInfo.cs