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
- ApplyImportsAction.cs
- XamlTreeBuilderBamlRecordWriter.cs
- ArgumentNullException.cs
- ApplicationBuildProvider.cs
- HttpBrowserCapabilitiesWrapper.cs
- CapabilitiesRule.cs
- EntityCollection.cs
- BinaryUtilClasses.cs
- ILGenerator.cs
- CustomLineCap.cs
- MailAddress.cs
- CroppedBitmap.cs
- TextProperties.cs
- DelegateSerializationHolder.cs
- VisualBrush.cs
- CodeDomLoader.cs
- FlowDocumentFormatter.cs
- DataService.cs
- XmlSiteMapProvider.cs
- XsdCachingReader.cs
- AxisAngleRotation3D.cs
- ScrollableControl.cs
- GifBitmapDecoder.cs
- ExpressionEditorSheet.cs
- RegisteredDisposeScript.cs
- EventWaitHandle.cs
- ForeignKeyConstraint.cs
- FSWPathEditor.cs
- SqlProfileProvider.cs
- entitydatasourceentitysetnameconverter.cs
- Util.cs
- CodeDOMProvider.cs
- StateItem.cs
- ManagementInstaller.cs
- SystemKeyConverter.cs
- HttpListenerContext.cs
- SchemaObjectWriter.cs
- ClientTargetSection.cs
- PositiveTimeSpanValidator.cs
- CodeAccessPermission.cs
- ProxyWebPartManager.cs
- BitVector32.cs
- Html32TextWriter.cs
- PermissionListSet.cs
- WizardDesigner.cs
- InheritanceAttribute.cs
- TextRangeEditLists.cs
- InlinedAggregationOperator.cs
- DataServiceRequestException.cs
- BindableTemplateBuilder.cs
- LicFileLicenseProvider.cs
- StrongNameIdentityPermission.cs
- SqlUserDefinedTypeAttribute.cs
- WsdlInspector.cs
- PlatformNotSupportedException.cs
- DataTrigger.cs
- WebScriptEndpoint.cs
- DetailsViewInsertEventArgs.cs
- BackgroundFormatInfo.cs
- DataBoundControlHelper.cs
- TreeNodeCollection.cs
- ScrollItemPatternIdentifiers.cs
- SQLUtility.cs
- BitmapEffectOutputConnector.cs
- DataGridViewCellMouseEventArgs.cs
- MessageHeaderInfoTraceRecord.cs
- WindowsGrip.cs
- _Events.cs
- InvalidCardException.cs
- SystemIcmpV6Statistics.cs
- PenCursorManager.cs
- DataContractAttribute.cs
- SqlUtils.cs
- SuppressMergeCheckAttribute.cs
- SchemaImporterExtension.cs
- XmlDictionaryReader.cs
- UserControlBuildProvider.cs
- SortQueryOperator.cs
- ByteStream.cs
- IdentitySection.cs
- ReadWriteObjectLock.cs
- ZoneIdentityPermission.cs
- DocumentPaginator.cs
- WindowsNonControl.cs
- HierarchicalDataBoundControlAdapter.cs
- JoinElimination.cs
- AssemblyAttributesGoHere.cs
- EventlogProvider.cs
- VirtualizingStackPanel.cs
- XmlSignificantWhitespace.cs
- ListViewInsertedEventArgs.cs
- HashHelper.cs
- Constraint.cs
- XPathBinder.cs
- DecoderNLS.cs
- MetaData.cs
- Dictionary.cs
- ToolTip.cs
- DataGridViewIntLinkedList.cs
- UIPermission.cs