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
- LinkDesigner.cs
- IteratorDescriptor.cs
- ProgressBar.cs
- DispatchWrapper.cs
- AnnotationMap.cs
- Identity.cs
- WebReferenceOptions.cs
- CodeSubDirectory.cs
- EnumMemberAttribute.cs
- LiteralDesigner.cs
- Attribute.cs
- IgnorePropertiesAttribute.cs
- XmlAttributeAttribute.cs
- PartialCachingAttribute.cs
- ModuleBuilder.cs
- IntranetCredentialPolicy.cs
- PartialCachingControl.cs
- BitStream.cs
- HttpListenerResponse.cs
- StringInfo.cs
- BlockExpression.cs
- OdbcRowUpdatingEvent.cs
- DoubleAnimationClockResource.cs
- ExpressionBindingCollection.cs
- XpsFilter.cs
- FixedSOMImage.cs
- ErrorFormatterPage.cs
- ITreeGenerator.cs
- SoapIncludeAttribute.cs
- BitmapEffectInput.cs
- IndependentlyAnimatedPropertyMetadata.cs
- BindingValueChangedEventArgs.cs
- ExclusiveHandle.cs
- RefreshEventArgs.cs
- Int64Animation.cs
- ImagingCache.cs
- DoubleCollectionConverter.cs
- reliableinputsessionchannel.cs
- StorageMappingFragment.cs
- CodeDelegateInvokeExpression.cs
- DbConnectionStringCommon.cs
- TemplateManager.cs
- DataAccessor.cs
- StorageMappingItemLoader.cs
- WindowsSlider.cs
- GroupItem.cs
- XmlTextAttribute.cs
- WebPartConnectionsDisconnectVerb.cs
- HtmlTableCell.cs
- HttpCapabilitiesEvaluator.cs
- RepeaterItemCollection.cs
- HtmlInputCheckBox.cs
- _FixedSizeReader.cs
- ToolStripSeparator.cs
- SchemaImporter.cs
- HttpRequestTraceRecord.cs
- ExpressionCopier.cs
- AuthorizationRule.cs
- HttpErrorTraceRecord.cs
- ApplicationFileParser.cs
- SourceFilter.cs
- Style.cs
- EntityReference.cs
- ImageDrawing.cs
- LazyTextWriterCreator.cs
- UserUseLicenseDictionaryLoader.cs
- XamlSerializer.cs
- dtdvalidator.cs
- wgx_exports.cs
- CookielessHelper.cs
- StringResourceManager.cs
- ToolStripItemRenderEventArgs.cs
- Drawing.cs
- XComponentModel.cs
- CompoundFileStorageReference.cs
- UnmanagedMemoryStreamWrapper.cs
- ScrollBarAutomationPeer.cs
- NameValueSectionHandler.cs
- DiffuseMaterial.cs
- AttachedAnnotation.cs
- PrintingPermissionAttribute.cs
- DBNull.cs
- HitTestDrawingContextWalker.cs
- ExceptionNotification.cs
- StringComparer.cs
- XmlDataSource.cs
- ListControlConvertEventArgs.cs
- ComponentResourceManager.cs
- GeneralTransform3D.cs
- HtmlTableRow.cs
- XPathNodeList.cs
- SoapSchemaMember.cs
- StringPropertyBuilder.cs
- WCFBuildProvider.cs
- SiteMapPath.cs
- PathTooLongException.cs
- XmlAtomicValue.cs
- DecoderNLS.cs
- Application.cs
- SecurityHelper.cs