Исключение KeyNotFoundException в Dictionary - C#
Формулировка задачи:
Не много не могу понять почему мне VS выдает исключение
Чтобы не впутывать в работу программы, показываю только часть объявления кода, если нужно то выложу весь код.
public class Protocol
{
String q;
Char a;
public Protocol(String q, Char a)
{
this.q = q;
this.a = a;
}
public void SetProtocol(String q, Char a)
{
this.q = q;
this.a = a;
}
public String State
{
get {
return q;
}
set {
q = value;
}
}
public Char Symbol
{
get {
return a;
}
set {
a = value;
}
}
}Dictionary<Protocol,TransformTo> Commands; private Protocol CurrentProtocol;
Решение задачи: «Исключение KeyNotFoundException в Dictionary»
textual
Листинг программы
public override bool Equals(object obj)
{
Protocol protocol = obj as Protocol;
return protocol != null && State.Equals(protocol.State) && Symbol.Equals(protocol.Symbol);
}
public override int GetHashCode()
{
return State.GetHashCode() ^ Symbol.GetHashCode();
}