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
- PlacementWorkspace.cs
- XmlQueryOutput.cs
- ProcessingInstructionAction.cs
- BridgeDataReader.cs
- CallId.cs
- WebResponse.cs
- KeyboardNavigation.cs
- ReferentialConstraint.cs
- ModelTypeConverter.cs
- TableHeaderCell.cs
- XmlSubtreeReader.cs
- TableRowGroupCollection.cs
- TypedDataSourceCodeGenerator.cs
- GridViewUpdatedEventArgs.cs
- SqlAliasesReferenced.cs
- ErrorHandlingReceiver.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- WebPartMovingEventArgs.cs
- DataListItem.cs
- ConfigXmlReader.cs
- TypeListConverter.cs
- DataTableTypeConverter.cs
- SystemInfo.cs
- ResolveMatchesCD1.cs
- AuthenticatingEventArgs.cs
- URI.cs
- PropertyPathWorker.cs
- TraceSwitch.cs
- SqlMethods.cs
- JpegBitmapDecoder.cs
- TextServicesContext.cs
- TextTrailingCharacterEllipsis.cs
- SystemIPInterfaceProperties.cs
- CodeFieldReferenceExpression.cs
- NumericExpr.cs
- TimelineCollection.cs
- LineSegment.cs
- ProgressBar.cs
- AssemblySettingAttributes.cs
- Menu.cs
- TreeNodeClickEventArgs.cs
- VScrollBar.cs
- GiveFeedbackEventArgs.cs
- ColorTransformHelper.cs
- WindowsFormsLinkLabel.cs
- WorkflowPageSetupDialog.cs
- ListItemCollection.cs
- InputManager.cs
- ByteStream.cs
- ConfigurationLocation.cs
- ImageAttributes.cs
- RubberbandSelector.cs
- SystemNetworkInterface.cs
- WindowsGraphics.cs
- AVElementHelper.cs
- NameValueSectionHandler.cs
- ObjectListCommandEventArgs.cs
- PackagePartCollection.cs
- FieldToken.cs
- ServerValidateEventArgs.cs
- FirewallWrapper.cs
- ToolStripGrip.cs
- EntitySetRetriever.cs
- Native.cs
- input.cs
- TextSearch.cs
- CodeMethodMap.cs
- IOThreadTimer.cs
- CompiledIdentityConstraint.cs
- NumberAction.cs
- TextBox.cs
- BinaryReader.cs
- DataGrid.cs
- UrlMappingsSection.cs
- SHA1CryptoServiceProvider.cs
- CodeLabeledStatement.cs
- ChannelSinkStacks.cs
- ResXResourceWriter.cs
- InputChannelAcceptor.cs
- ConnectionProviderAttribute.cs
- Schema.cs
- DocobjHost.cs
- ToolboxCategory.cs
- HttpCachePolicyWrapper.cs
- ParallelEnumerable.cs
- XmlArrayAttribute.cs
- ModuleBuilder.cs
- Underline.cs
- SymmetricCryptoHandle.cs
- WebBaseEventKeyComparer.cs
- NetSectionGroup.cs
- ProtectedConfiguration.cs
- ObjectToIdCache.cs
- XPathLexer.cs
- XhtmlConformanceSection.cs
- DBPropSet.cs
- EdgeModeValidation.cs
- AnnotationMap.cs
- TreeViewImageIndexConverter.cs
- addressfiltermode.cs