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
- XPathArrayIterator.cs
- TextElementCollectionHelper.cs
- Activity.cs
- DetailsViewInsertEventArgs.cs
- MeasureItemEvent.cs
- WebPartZoneCollection.cs
- ScriptReferenceBase.cs
- FrameworkElement.cs
- SqlRemoveConstantOrderBy.cs
- LongValidator.cs
- HtmlInputSubmit.cs
- UrlPath.cs
- DiagnosticTraceSource.cs
- RectangleConverter.cs
- typedescriptorpermission.cs
- SqlParameterCollection.cs
- DataGridViewTextBoxEditingControl.cs
- TriggerCollection.cs
- DataConnectionHelper.cs
- ValueQuery.cs
- QueryResponse.cs
- LabelAutomationPeer.cs
- PersonalizationDictionary.cs
- SmiTypedGetterSetter.cs
- SecureConversationServiceElement.cs
- SizeAnimationClockResource.cs
- ProxyWebPartConnectionCollection.cs
- LineBreak.cs
- SessionStateUtil.cs
- FlowDocumentView.cs
- basemetadatamappingvisitor.cs
- File.cs
- DeviceSpecificDialogCachedState.cs
- Range.cs
- EventlogProvider.cs
- ServiceOperationViewControl.cs
- ReceiveParametersContent.cs
- StaticContext.cs
- ProfileInfo.cs
- TaskbarItemInfo.cs
- DelegateBodyWriter.cs
- PlatformCulture.cs
- UnauthorizedWebPart.cs
- RuleRefElement.cs
- PageCodeDomTreeGenerator.cs
- Span.cs
- Handle.cs
- COM2PictureConverter.cs
- StructureChangedEventArgs.cs
- CounterCreationDataCollection.cs
- PersistChildrenAttribute.cs
- HtmlElement.cs
- SqlCommand.cs
- DbConnectionPoolGroup.cs
- Decorator.cs
- EntityTemplateFactory.cs
- AccessViolationException.cs
- DetailsViewUpdatedEventArgs.cs
- LinkLabel.cs
- KeyGestureValueSerializer.cs
- AddInStore.cs
- PreservationFileReader.cs
- InsufficientMemoryException.cs
- ExpressionNormalizer.cs
- MemberDescriptor.cs
- CryptoApi.cs
- AssemblyUtil.cs
- GlobalizationSection.cs
- ToolboxDataAttribute.cs
- RelationshipEnd.cs
- CfgArc.cs
- TcpAppDomainProtocolHandler.cs
- DrawListViewItemEventArgs.cs
- BaseDataList.cs
- DataColumnPropertyDescriptor.cs
- HtmlMeta.cs
- CorrelationTokenInvalidatedHandler.cs
- DataGridViewRowConverter.cs
- SafeLibraryHandle.cs
- TreeViewDataItemAutomationPeer.cs
- Int16Storage.cs
- TrustVersion.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- DbConnectionPool.cs
- IOException.cs
- HttpResponse.cs
- DurableEnlistmentState.cs
- RowToParametersTransformer.cs
- CryptoProvider.cs
- XmlBinaryWriterSession.cs
- FilterableAttribute.cs
- Missing.cs
- CalendarDesigner.cs
- TextParentUndoUnit.cs
- ManagementQuery.cs
- LookupNode.cs
- SQLMoney.cs
- ScrollProviderWrapper.cs
- _SSPISessionCache.cs
- ScrollItemPattern.cs