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
- XslAstAnalyzer.cs
- RegexRunner.cs
- UIElementParagraph.cs
- basecomparevalidator.cs
- TypeDelegator.cs
- CommandHelpers.cs
- JsonMessageEncoderFactory.cs
- TextFormatterImp.cs
- XmlDocumentFragment.cs
- HostedTransportConfigurationBase.cs
- BinaryObjectWriter.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- DateTimeStorage.cs
- ViewStateException.cs
- HtmlTableCellCollection.cs
- DataColumnMappingCollection.cs
- XhtmlBasicSelectionListAdapter.cs
- TreeNodeSelectionProcessor.cs
- ClientSettingsSection.cs
- cookiecontainer.cs
- WebPartManager.cs
- StorageComplexTypeMapping.cs
- ExceptionHandler.cs
- TreeNodeConverter.cs
- EventHandlers.cs
- Attachment.cs
- SimpleHandlerFactory.cs
- CustomTokenProvider.cs
- ProcessHost.cs
- VectorCollection.cs
- TemplateBamlTreeBuilder.cs
- DecoratedNameAttribute.cs
- ToolStripDropDownClosingEventArgs.cs
- TrackBar.cs
- ManipulationDeltaEventArgs.cs
- ScrollChrome.cs
- EntityStoreSchemaFilterEntry.cs
- PackageStore.cs
- RoleGroupCollection.cs
- WhitespaceRuleLookup.cs
- SessionStateSection.cs
- ScriptServiceAttribute.cs
- ReadOnlyHierarchicalDataSource.cs
- CompilerTypeWithParams.cs
- BitmapEffectDrawingContent.cs
- CopyAttributesAction.cs
- ObjectReaderCompiler.cs
- HierarchicalDataSourceControl.cs
- ComponentResourceKey.cs
- DataGridGeneralPage.cs
- DateTimeConstantAttribute.cs
- StringArrayConverter.cs
- SerializationTrace.cs
- XmlAutoDetectWriter.cs
- PermissionAttributes.cs
- EditorPart.cs
- RightsManagementPermission.cs
- Clock.cs
- MetaType.cs
- ModuleBuilder.cs
- PageContentCollection.cs
- UserInitiatedRoutedEventPermission.cs
- ConstrainedDataObject.cs
- GeometryHitTestParameters.cs
- ReflectTypeDescriptionProvider.cs
- CodePageUtils.cs
- Options.cs
- DataGridViewButtonColumn.cs
- OutKeywords.cs
- ReferenceConverter.cs
- SrgsElementList.cs
- CryptoKeySecurity.cs
- TableParaClient.cs
- SourceFileBuildProvider.cs
- ParserContext.cs
- DataProtection.cs
- XmlValidatingReader.cs
- XamlParser.cs
- DelayedRegex.cs
- ToolStripSeparator.cs
- PageRouteHandler.cs
- DockPatternIdentifiers.cs
- TablePatternIdentifiers.cs
- RootBrowserWindowProxy.cs
- BitmapFrame.cs
- IconBitmapDecoder.cs
- ShaperBuffers.cs
- WebPartChrome.cs
- ProviderSettingsCollection.cs
- EDesignUtil.cs
- OleDbPermission.cs
- XhtmlBasicCommandAdapter.cs
- ColumnMapVisitor.cs
- XmlSchemaExporter.cs
- HandledMouseEvent.cs
- DbDeleteCommandTree.cs
- WebServiceBindingAttribute.cs
- RouteItem.cs
- GrammarBuilderRuleRef.cs