采用动态与泛型集合在.NET4的时候无法理解的异常 [英] Can't understand the Exception when using dynamic with generic collection in .net4

查看:142
本文介绍了采用动态与泛型集合在.NET4的时候无法理解的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检查下面请了code:

check the code below please:

static void Main(string[] args) {
    IList<dynamic> items = new List<dynamic>();
    items.Add(3);
    items.Add("solid");
    dynamic i = new ExpandoObject();
    items.Add(i); //System.Collections.Generic.IList<object>' does not contain a definition for 'Add'
    Console.WriteLine();
}

这是在动态机制中的错误?

is this a bug in "dynamic" mechanism?

推荐答案

看起来像一个bug(或者是一个功能要求?):

Looks like a bug (or is it a feature request?):

<一个href="https://connect.microsoft.com/VisualStudio/feedback/details/534288/ilist-dynamic-cannot-call-a-method-add-without-casting" rel="nofollow">https://connect.microsoft.com/VisualStudio/feedback/details/534288/ilist-dynamic-cannot-call-a-method-add-without-casting

这篇关于采用动态与泛型集合在.NET4的时候无法理解的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆