AnonymousType匿名类型和对象之间的转换

本文转载:http://www.cnblogs.com/dean-Wei/p/3150553.html

一、匿名对象转换为对象。

1、问题:

2、解决方案:强制指定类型。

解决之。

 

 

 

二、 对象转换为匿名对象。

               XElement t = xmlResponResult;
                //执行API信用卡退款后返回结果。
                var refundResponse = new
                             {
                                 result = t.Element("result").Value,
                                 responsecode = t.Element("responsecode").Value,
                                 transactionID = t.Element("tranid").Value,//TransactionID
                                 authcode = t.Element("authcode").Value,
                                 item_number = t.Element("trackid").Value,//item_number
                                 merchantid = t.Element("merchantid").Value,
                                 refund_id = t.Element("udf1").Value,
                                 account_id = t.Element("udf2").Value,
                                 bill_amount = t.Element("udf3").Value,
                                 bill_currencycode = t.Element("udf4").Value
                             };

posted @ 2013-11-08 10:19  跟着阿笨一起玩.NET  阅读(1075)  评论(0编辑  收藏  举报