小编Ger*_*d K的帖子

向IList <T>添加动态失败

在下面的代码示例调用l.Add(s)c.Add(s)成功,但对于一般的,当它失败IList<string>.

    var l = new List<string>();
    dynamic s = "s";
    l.Add(s);
    var c = (ICollection<string>)l;
    c.Add(s);
    var i = (IList<string>)l;
    i.Add("s"); // works
    i.Add(s); // fails
Run Code Online (Sandbox Code Playgroud)

https://dotnetfiddle.net/Xll2If

未处理的异常:Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:方法'Add'的重载在System.Dynamic.Uynamic.UpdateDelegates.UpdateAndExecuteVoid2 [T0,T1]的CallSite.Target(Closure,CallSite,IList`1,Object)中取'1'参数](CallSite网站,T0 arg0,T1 arg1)位于C:\ Dev\PlayGround\PlayGround\Program.cs中的Program.Main():第13行

IList<T>来源于ICollection<T>.有人可以解释为什么呼叫IList.Add失败?

c# dynamic

10
推荐指数
1
解决办法
336
查看次数

是否有sql_dump的Cake 3替代品

在CakePhp <3中,可以使用调试视图获取已执行查询的列表

echo $this->element('sql_dump');
Run Code Online (Sandbox Code Playgroud)

在Cake 3中,相应的元素文件不再是核心.是否有蛋糕3相当于?我在迁移指南中找不到任何相关内容.

cakephp cakephp-3.0

1
推荐指数
1
解决办法
1304
查看次数

标签 统计

c# ×1

cakephp ×1

cakephp-3.0 ×1

dynamic ×1