When i run the following code :
var aList = new List<string>{"a", "b", "c"};
dynamic a = aList.Where(item => item.StartsWith("a"));
dynamic b = a.Count();
Microsoft.CSharp.RuntimeBinder.RunTimeBinderException raises.
But when I write a code snippet like this:
public interface IInterface
{
}
public class InterfaceImplementor:IInterface
{
public int ID = 10;
public static IInterface Execute()
{
return new InterfaceImplementor();
}
}
public class MyClass
{
public static void Main()
{
dynamic x = InterfaceImplementor.Execute();
Console.WriteLine(x.ID);
}
}
it's work.
Why first code snippet doesn't work?