'System.Collections.Generic.IList <object>' enthält keine Definition für 'Add' bei Verwendung von 'dynamic' und 'ExpandoObject'
Sagen Sie, ich habe eine Klasse, Foo, die ungefähr so aussieht:
public class Foo : IFoo
{
public Foo()
{
Bars = new List<dynamic>();
}
public IList<dynamic> Bars { get; set; }
}
Das Interface IFoo sieht folgendermaßen aus:
public interface IFoo
{
IList<dynamic> Bars { get; set; }
}
Nun, wenn ich Folgendes mache:
IFoo foo = new Foo();
dynamic a = new System.Dynamic.ExpandoObject();
a.Prop = 10000;
dynamic b = new System.Dynamic.ExpandoObject();
b.Prop = "Some Text";
foo.Bars.Add(a); // Throws an 'System.Collections.Generic.IList<object>' does not contain a definition for 'Add' - exception!!!!!
foo.Bars.Add(b); // Same here!!!!!
Was mache ich hier falsch ?????