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
- FixedSOMElement.cs
- AspNetPartialTrustHelpers.cs
- PresentationSource.cs
- ResourceExpressionBuilder.cs
- RemotingAttributes.cs
- SelectiveScrollingGrid.cs
- SafeBuffer.cs
- DeclaredTypeValidatorAttribute.cs
- InternalBufferOverflowException.cs
- MsmqActivation.cs
- RadioButtonDesigner.cs
- EntityDesignerUtils.cs
- AQNBuilder.cs
- WsatEtwTraceListener.cs
- _ListenerResponseStream.cs
- CfgRule.cs
- DefaultProxySection.cs
- PropertyFilter.cs
- IntegerFacetDescriptionElement.cs
- EncoderNLS.cs
- StandardRuntimeEnumValidatorAttribute.cs
- CodeDefaultValueExpression.cs
- Msec.cs
- cryptoapiTransform.cs
- GroupDescription.cs
- VirtualDirectoryMapping.cs
- Int32KeyFrameCollection.cs
- ToolStripPanelCell.cs
- CssStyleCollection.cs
- Encoder.cs
- StringUtil.cs
- ToolBarTray.cs
- AppSettings.cs
- Int16AnimationUsingKeyFrames.cs
- _SingleItemRequestCache.cs
- invalidudtexception.cs
- CacheModeValueSerializer.cs
- ArrangedElementCollection.cs
- ObjectResult.cs
- OperationCanceledException.cs
- SafeCloseHandleCritical.cs
- DataGridViewRowConverter.cs
- TabItemWrapperAutomationPeer.cs
- ConnectionManagementSection.cs
- XmlCompatibilityReader.cs
- RepeaterItemEventArgs.cs
- SqlConnectionStringBuilder.cs
- ColorTranslator.cs
- MailMessageEventArgs.cs
- Binding.cs
- DateTimeConverter2.cs
- UDPClient.cs
- FontSizeConverter.cs
- SecurityPermission.cs
- EncryptedReference.cs
- TreeViewEvent.cs
- LoggedException.cs
- ConfigUtil.cs
- Timer.cs
- NameSpaceEvent.cs
- clipboard.cs
- WriteStateInfoBase.cs
- LinqDataSourceDeleteEventArgs.cs
- CompositeActivityTypeDescriptorProvider.cs
- SelectionPattern.cs
- WindowsHyperlink.cs
- Oid.cs
- ProcessRequestArgs.cs
- DelegatingTypeDescriptionProvider.cs
- OLEDB_Enum.cs
- GPStream.cs
- Metafile.cs
- ViewStateModeByIdAttribute.cs
- CircleHotSpot.cs
- SerialErrors.cs
- DesignerView.cs
- DataList.cs
- MailHeaderInfo.cs
- CompositeActivityCodeGenerator.cs
- Hyperlink.cs
- FormsAuthenticationEventArgs.cs
- AutomationPeer.cs
- SchemaImporterExtension.cs
- CapabilitiesAssignment.cs
- InertiaTranslationBehavior.cs
- DatatypeImplementation.cs
- RepeaterCommandEventArgs.cs
- PocoPropertyAccessorStrategy.cs
- DrawingBrush.cs
- ClientTarget.cs
- TextElementEnumerator.cs
- EtwTrackingParticipant.cs
- InternalPermissions.cs
- CompilationSection.cs
- BlobPersonalizationState.cs
- ArgumentNullException.cs
- LambdaCompiler.Logical.cs
- SkipStoryboardToFill.cs
- CreateUserWizardDesigner.cs
- ModifyActivitiesPropertyDescriptor.cs