Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Extensions / Util / Pair.cs / 1305376 / Pair.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Util {
using System;
// Generic Pair class. Overrides Equals() and GetHashCode(), so it can be used as a dictionary key.
internal sealed class Pair {
private readonly TFirst _first;
private readonly TSecond _second;
public Pair(TFirst first, TSecond second) {
_first = first;
_second = second;
}
public TFirst First {
get {
return _first;
}
}
public TSecond Second {
get {
return _second;
}
}
public override bool Equals(object obj) {
if (obj == this) {
return true;
}
Pair other = obj as Pair;
return (other != null) &&
(((other._first == null) && (_first == null)) ||
((other._first != null) && other._first.Equals(_first))) &&
(((other._second == null) && (_second == null)) ||
((other._second != null) && other._second.Equals(_second)));
}
public override int GetHashCode() {
int a = (_first == null) ? 0 : _first.GetHashCode();
int b = (_second == null) ? 0 : _second.GetHashCode();
return HashCodeCombiner.CombineHashCodes(a, b);
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Util {
using System;
// Generic Pair class. Overrides Equals() and GetHashCode(), so it can be used as a dictionary key.
internal sealed class Pair {
private readonly TFirst _first;
private readonly TSecond _second;
public Pair(TFirst first, TSecond second) {
_first = first;
_second = second;
}
public TFirst First {
get {
return _first;
}
}
public TSecond Second {
get {
return _second;
}
}
public override bool Equals(object obj) {
if (obj == this) {
return true;
}
Pair other = obj as Pair;
return (other != null) &&
(((other._first == null) && (_first == null)) ||
((other._first != null) && other._first.Equals(_first))) &&
(((other._second == null) && (_second == null)) ||
((other._second != null) && other._second.Equals(_second)));
}
public override int GetHashCode() {
int a = (_first == null) ? 0 : _first.GetHashCode();
int b = (_second == null) ? 0 : _second.GetHashCode();
return HashCodeCombiner.CombineHashCodes(a, b);
}
}
}
// 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
- Int32.cs
- DesignerWidgets.cs
- RegexMatch.cs
- InfoCard.cs
- SQLDateTime.cs
- IndexedEnumerable.cs
- RegexWriter.cs
- SeparatorAutomationPeer.cs
- RSAOAEPKeyExchangeFormatter.cs
- AttributedMetaModel.cs
- XmlSchemaAnnotated.cs
- MethodToken.cs
- TrackingStringDictionary.cs
- LayoutTableCell.cs
- SerializationInfoEnumerator.cs
- EndPoint.cs
- AttributeData.cs
- ClientSettingsSection.cs
- BuilderElements.cs
- QueryResult.cs
- VirtualPath.cs
- SqlUserDefinedTypeAttribute.cs
- TextWriter.cs
- IdentityHolder.cs
- BamlResourceContent.cs
- AlphaSortedEnumConverter.cs
- CodeArrayCreateExpression.cs
- GeneralTransform2DTo3D.cs
- Calendar.cs
- ControlEvent.cs
- Material.cs
- FunctionUpdateCommand.cs
- UnionExpr.cs
- EmptyEnumerator.cs
- DocumentEventArgs.cs
- InitializationEventAttribute.cs
- NumberFunctions.cs
- ValueQuery.cs
- TokenBasedSetEnumerator.cs
- HttpHandlersSection.cs
- TrimSurroundingWhitespaceAttribute.cs
- RegexFCD.cs
- PrimitiveDataContract.cs
- Header.cs
- WorkflowRuntimeServiceElementCollection.cs
- ExeContext.cs
- WebGetAttribute.cs
- PropertySet.cs
- CursorConverter.cs
- Scene3D.cs
- InfoCardConstants.cs
- IisTraceListener.cs
- SerTrace.cs
- NotificationContext.cs
- FrameworkElementAutomationPeer.cs
- Publisher.cs
- LinqToSqlWrapper.cs
- Vector3D.cs
- SqlCaseSimplifier.cs
- VectorKeyFrameCollection.cs
- OutputScopeManager.cs
- Currency.cs
- Vector3dCollection.cs
- ECDiffieHellmanCng.cs
- FormViewModeEventArgs.cs
- TypeUnloadedException.cs
- SqlErrorCollection.cs
- GridViewColumn.cs
- WebPartDisplayModeCollection.cs
- sqlstateclientmanager.cs
- linebase.cs
- ByeMessageCD1.cs
- ObjectRef.cs
- OwnerDrawPropertyBag.cs
- MinimizableAttributeTypeConverter.cs
- Transform.cs
- CategoryAttribute.cs
- ValidatorCompatibilityHelper.cs
- GestureRecognitionResult.cs
- SqlDataSourceTableQuery.cs
- CategoryValueConverter.cs
- BufferModesCollection.cs
- XmlObjectSerializerReadContextComplex.cs
- EntryIndex.cs
- SmtpFailedRecipientException.cs
- DirectoryInfo.cs
- EventSinkHelperWriter.cs
- MimeTextImporter.cs
- NeutralResourcesLanguageAttribute.cs
- URLMembershipCondition.cs
- Binding.cs
- ColumnBinding.cs
- TransformerConfigurationWizardBase.cs
- _ListenerRequestStream.cs
- CreateUserWizard.cs
- SqlCommandBuilder.cs
- LoginDesigner.cs
- BaseValidator.cs
- XmlUtil.cs
- TextRenderingModeValidation.cs