zoukankan      html  css  js  c++  java
  • 再论dynamic 关键字

    有关动态数据类型 ,大家估计在实际中用的比较多了,不是很陌生。有关自己在项目中 的实际钉子总结:

    1  匿名对象中的字段,是只读的,不能赋值

    2 动态类型 指向强类型实例,注意观察内部的属性可访问性

    3 随时创建匿名对象给动态类型或许是更好的方法。

     dynamic msg=null;
                try
                {
     
    
                    var snInfos = bll_RepairOrderService.GetTheVendorBuyProductsSNInfos(Id, Mid);
     
                    if (null != snInfos && snInfos.Count > 0)
                    {
    
                        var results = new List<string>();
                        foreach (var item in snInfos)
                        {
                            results.Add(item.InternalSN);
                        }
                        msg = new { _s = 1, _d = results };
     
                    }
                    else
                    {
                        //msg.Status = MessageStatus.Error;
                        // msg.Results = null;
                        msg = new { _s = 1, _d = string.Format("经销商编码:{0}!", Id) };
                    }
  • 相关阅读:
    1月10日 TextView
    1月9日 布局2
    30 Adapter适配器
    29 个人通讯录列表(一)
    28 ListView控件
    27 登录模板
    26 Activity的启动模式
    25 Activity的生命周期
    24 得到Activity返回的数据
    23 Activity的传值2(bundle)
  • 原文地址:https://www.cnblogs.com/micro-chen/p/4236290.html
Copyright © 2011-2022 走看看