dynamic data = new System.Dynamic.ExpandoObject();
IDictionary<string, object> dictionary = (IDictionary<string, object>)data;
dictionary.Add("FirstName", "Bob");
dictionary.Add("LastName", "Smith");
dictionary.Add("Arry_01", new List<object>());
dynamic data1 = new System.Dynamic.ExpandoObject();
((IDictionary<string, object>)data1).Add("AAA","=101");
((IDictionary<string, object>)data1).Add("BBB","=101");
data.Arry_01.Add(data1);
        private void button1_Click(object sender, EventArgs e)
{ dynamic expando = new ExpandoObject();
expando.Name = "Brian";
expando.Country = "USA";
// Add properties dynamically to expando
AddProperty(expando, "Language", "English"); // Add a LanguageChanged event and predefined event handler
AddEvent(expando, "LanguageChanged", eventHandler);
    }
  public static void AddProperty(ExpandoObject expando, string propertyName, object propertyValue)
{
//扩展对象支持IDictionary,因此我们可以像这样扩展它
var expandoDict = expando as IDictionary<string, object>;
if (expandoDict.ContainsKey(propertyName)) //是否包含该属性
expandoDict[propertyName] = propertyValue;
else
expandoDict.Add(propertyName, propertyValue);
} public static void AddEvent(ExpandoObject expando, string eventName, Action<object, EventArgs> handler)
{
var expandoDict = expando as IDictionary<string, object>;
if (expandoDict.ContainsKey(eventName))
expandoDict[eventName] = handler;
else
expandoDict.Add(eventName, handler);
}
public event Action<object, EventArgs> eventHandler;

最新文章

  1. ionic之$ionicGesture手势(大坑)
  2. qq空间返回顶部代码
  3. HDU2203 亲和串
  4. Android学习笔记——Button
  5. WebApp之Meta标签
  6. ubuntu13.04 nfs配置
  7. JDBC连接SQL Server2008
  8. tiny4412的中断资源连接关系示意图
  9. czxt
  10. Python遍历文件夹枚举所有文件类型
  11. JavaScript学习总结二(Date对象的用法)
  12. BZOJ 1733: [Usaco2005 feb]Secret Milking Machine 神秘的挤奶机
  13. hdu find the safest road
  14. 递推计数-hdu-4747-Mex
  15. 基于Asterisk的VoIP开发指南——(1)实现基本呼叫功能
  16. Delphi获取其它进程窗口句柄的3种方法
  17. 匹配PC和移动端
  18. ASE加密
  19. [bzoj3287] Mato的刷屏计划
  20. card card card HDU - 6205

热门文章

  1. Tensor Flow基础(2.0)
  2. mysql——操作数据库
  3. [转帖]linux中systemctl详细理解及常用命令
  4. ABC136E Max GCD
  5. 认识并学会springCloud的使用
  6. 第二大矩阵面积--(stack)牛客多校第二场-- Second Large Rectangle
  7. O004、启动第一个KVM虚机
  8. WPF中关于合并资源字典
  9. 用ant打包
  10. ros 封ip,域名,端口,重定向