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
- FormatVersion.cs
- XmlComplianceUtil.cs
- UniqueEventHelper.cs
- ThicknessKeyFrameCollection.cs
- List.cs
- PageTheme.cs
- ScrollBar.cs
- HostDesigntimeLicenseContext.cs
- Brushes.cs
- CompilerTypeWithParams.cs
- XmlSchemaSimpleTypeList.cs
- LabelLiteral.cs
- AssociationType.cs
- OrthographicCamera.cs
- _HeaderInfoTable.cs
- FrameworkElement.cs
- CustomServiceCredentials.cs
- SizeConverter.cs
- ChildChangedEventArgs.cs
- CodeAssignStatement.cs
- RTLAwareMessageBox.cs
- WindowsRichEditRange.cs
- ObjectListShowCommandsEventArgs.cs
- SqlCacheDependency.cs
- MenuRendererClassic.cs
- InstanceKeyCompleteException.cs
- MetadataExporter.cs
- ColorAnimationUsingKeyFrames.cs
- InheritanceContextHelper.cs
- CallContext.cs
- RegexCompiler.cs
- SecondaryIndexDefinition.cs
- LayoutTable.cs
- BindValidator.cs
- MsiStyleLogWriter.cs
- FillBehavior.cs
- CollectionExtensions.cs
- DoubleCollection.cs
- SamlSubjectStatement.cs
- KeyPressEvent.cs
- ZipPackagePart.cs
- TextServicesContext.cs
- Token.cs
- MostlySingletonList.cs
- StrokeRenderer.cs
- ExtensibleClassFactory.cs
- BasePropertyDescriptor.cs
- srgsitem.cs
- Normalization.cs
- ActivityExecutorSurrogate.cs
- MessageDroppedTraceRecord.cs
- MenuRenderer.cs
- Color.cs
- DictionarySurrogate.cs
- DbCommandTree.cs
- SqlConnectionStringBuilder.cs
- CultureTable.cs
- SoapReflector.cs
- ValidatorCompatibilityHelper.cs
- DetailsViewInsertedEventArgs.cs
- ButtonBaseAdapter.cs
- HotSpot.cs
- SafeEventLogWriteHandle.cs
- WindowsScroll.cs
- SoapReflectionImporter.cs
- HelpEvent.cs
- ComponentSerializationService.cs
- SqlProfileProvider.cs
- RemoteWebConfigurationHostServer.cs
- UnsafeNativeMethods.cs
- DataColumnSelectionConverter.cs
- TextRangeEditTables.cs
- DataGridTextBoxColumn.cs
- NavigationEventArgs.cs
- IncrementalReadDecoders.cs
- DictionaryBase.cs
- TextDecorationUnitValidation.cs
- SQLGuidStorage.cs
- TdsValueSetter.cs
- ForeignKeyFactory.cs
- CodeDirectoryCompiler.cs
- OdbcPermission.cs
- XhtmlCssHandler.cs
- DefaultProxySection.cs
- FloaterParagraph.cs
- SqlDependency.cs
- XmlRawWriterWrapper.cs
- RijndaelCryptoServiceProvider.cs
- ToolStripSplitButton.cs
- DisplayNameAttribute.cs
- HandlerWithFactory.cs
- ByteViewer.cs
- ClientSection.cs
- ConfigurationLocation.cs
- ObjectQueryState.cs
- ChangeNode.cs
- GridViewColumn.cs
- JumpPath.cs
- OleDbPropertySetGuid.cs
- Evidence.cs