I want to use a key (from new instance with the same property) to retrieve value. but it will get KeyNotFoundException.
class Program
{
static void Main(string[] args)
{
Dictionary<Keyclass, ValueClass> dic = new Dictionary<Keyclass, ValueClass>()
{
{ new Keyclass() { Key = "k1" }, new ValueClass() {Value = "v1"} },
{ new Keyclass() { Key = "k2" }, new ValueClass() {Value = "v2"} }
};
var key = new Keyclass() { Key = "k1" };
var value = dic[key];
}
}
public class Keyclass
{
public string Key { get; set; }
}
public class ValueClass
{
public string Value { get; set; }
}