Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DictionaryWorkshop.Implementation
- {
- public class MyKeyValuePair<TKey, TValue>
- {
- public TKey Key { get; private set; }
- public TValue Value { get; set; }
- public MyKeyValuePair<TKey,TValue> Next { get; set; }
- public MyKeyValuePair(TKey key, TValue value)
- {
- this.Key = key;
- this.Value = value;
- }
- public override bool Equals(object obj)
- {
- if (obj == null)
- return false;
- var other = obj as MyKeyValuePair<TKey, TValue>;
- if (other == null)
- return false;
- return this.Key.Equals(other.Key) && this.Value.Equals(other.Value);
- }
- public override int GetHashCode()
- {
- return this.MergeHashCode(this.Key.GetHashCode(), this.Value.GetHashCode());
- }
- private int MergeHashCode(int keyHash, int valueHash)
- {
- int hash = 5;
- hash = hash * 11 + keyHash.GetHashCode();
- hash = hash * 11 + valueHash.GetHashCode();
- return hash;
- }
- public override string ToString()
- {
- return $"{this.Key}" + $"{this.Value}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment