1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
20 /// General purpose class to represent a standard pair of values.
22 /// <typeparam name="TFirst">Type of the first value</typeparam>
23 /// <typeparam name="TSecond">Type of the second value</typeparam>
24 public class Pair
<TFirst
, TSecond
> : IEquatable
<Pair
<TFirst
, TSecond
>>
26 private readonly TFirst first
;
27 private readonly TSecond second
;
30 /// Constructs a pair with its values
32 /// <param name="first"></param>
33 /// <param name="second"></param>
34 public Pair(TFirst first
, TSecond second
)
47 get { return second; }
50 public override string ToString()
52 return first
+ " " + second
;
55 public bool Equals(Pair
<TFirst
, TSecond
> pair
)
61 return Equals(first
, pair
.first
) && Equals(second
, pair
.second
);
64 public override bool Equals(object obj
)
66 if (ReferenceEquals(this, obj
))
70 return Equals(obj
as Pair
<TFirst
, TSecond
>);
73 public override int GetHashCode()
75 return first
.GetHashCode() + 29 * second
.GetHashCode();