首页 > 其他 > 详细

C# return dynamic/anonymous type value as function result

时间:2014-04-03 23:58:21      阅读:515      评论:0      收藏:0      [点我收藏+]

 

 

 

 

 

function:

bubuko.com,布布扣
   public static dynamic GetAppSecret()
        {
            //string[] result = new string[] { "", "" };
            dynamic result = new System.Dynamic.ExpandoObject();

            result = new { appid="appid", appSecret = "appSecret" };

            return result;
        }
bubuko.com,布布扣

if you want to use the dynamic result function in a difference assembly, you should add following code to assemblyInfo.cs

[assembly: InternalsVisibleTo("WeChatSchools")]

 

 

 

invoke:

var secret = Helper.GetAppSecret();
app.t_appid = secret.appid;
app.t_appkey = secret.appSecret;

 

 

 

 

 

 

 

C# return dynamic/anonymous type value as function result,布布扣,bubuko.com

C# return dynamic/anonymous type value as function result

原文:http://www.cnblogs.com/zyip/p/3643447.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!