Dictionary.ContainsKey return False, but a want True
Posted
by SkyN
on Stack Overflow
See other posts from Stack Overflow
or by SkyN
Published on 2010-06-10T13:44:49Z
Indexed on
2010/06/10
13:52 UTC
Read the original article
Hit count: 250
c#
namespace Dic
{
public class Key
{
string name;
public Key(string n) { name = n; }
}
class Program
{
static string Test()
{
Key a = new Key("A");
Key b = new Key("A");
System.Collections.Generic.Dictionary<Key, int> d = new System.Collections.Generic.Dictionary<Key, int>();
d.Add(a, 1);
return d.ContainsKey(b).ToString();
}
static void Main(string[] args)
{
System.Console.WriteLine(Test());
}
}
}
I want TRUE!!!
© Stack Overflow or respective owner