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
- SqlProvider.cs
- RotateTransform.cs
- FlowLayout.cs
- LocationUpdates.cs
- SemaphoreSecurity.cs
- FileSystemWatcher.cs
- TextServicesContext.cs
- WebSysDescriptionAttribute.cs
- DataServiceQueryContinuation.cs
- HashLookup.cs
- PlanCompilerUtil.cs
- RoleManagerSection.cs
- BaseTreeIterator.cs
- ExpressionLink.cs
- SqlCrossApplyToCrossJoin.cs
- RepeaterDesigner.cs
- ChooseAction.cs
- arc.cs
- DataObjectAttribute.cs
- MouseGestureConverter.cs
- AmbientValueAttribute.cs
- MessageAction.cs
- Help.cs
- MediaCommands.cs
- CustomSignedXml.cs
- VSDExceptions.cs
- TypeSchema.cs
- DetailsViewModeEventArgs.cs
- DataBoundLiteralControl.cs
- WindowsHyperlink.cs
- SingleAnimation.cs
- TypedTableHandler.cs
- DataGridViewRowPrePaintEventArgs.cs
- MethodResolver.cs
- AsnEncodedData.cs
- DataControlFieldHeaderCell.cs
- ConnectorRouter.cs
- XamlParser.cs
- Model3DGroup.cs
- infer.cs
- WebExceptionStatus.cs
- ListViewCommandEventArgs.cs
- ContextActivityUtils.cs
- SecurityTokenProvider.cs
- NegatedCellConstant.cs
- MsmqTransportSecurity.cs
- MemberHolder.cs
- FileSystemWatcher.cs
- ThreadAttributes.cs
- LinearGradientBrush.cs
- ExpressionNode.cs
- DefinitionUpdate.cs
- UIElementHelper.cs
- CodeDomSerializationProvider.cs
- CompilerGeneratedAttribute.cs
- CheckBox.cs
- CheckBoxList.cs
- SystemBrushes.cs
- NotificationContext.cs
- TableCell.cs
- PointCollection.cs
- BitmapMetadata.cs
- TypeElement.cs
- FormViewActionList.cs
- RequestCachePolicyConverter.cs
- WindowsFormsLinkLabel.cs
- UnsafeNetInfoNativeMethods.cs
- EdmFunction.cs
- DesignerView.Commands.cs
- MeshGeometry3D.cs
- WindowsListViewItem.cs
- UnauthorizedAccessException.cs
- FastPropertyAccessor.cs
- ListControlConvertEventArgs.cs
- EastAsianLunisolarCalendar.cs
- SafeThreadHandle.cs
- WindowsFormsLinkLabel.cs
- ColumnWidthChangedEvent.cs
- Dispatcher.cs
- ToolStripRendererSwitcher.cs
- ArrayList.cs
- ServerProtocol.cs
- TreeNodeBinding.cs
- SendMailErrorEventArgs.cs
- MediaTimeline.cs
- KeyValueSerializer.cs
- future.cs
- ManagementScope.cs
- CursorConverter.cs
- LogArchiveSnapshot.cs
- OleDbRowUpdatedEvent.cs
- BufferModeSettings.cs
- HandleRef.cs
- SafeTimerHandle.cs
- DrawListViewItemEventArgs.cs
- StorageSetMapping.cs
- XmlAttributes.cs
- ColumnMapVisitor.cs
- WithStatement.cs
- CodeGenerator.cs