C# return dynamic/anonymous type value as function result

 

 

 

 

 

function:

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

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

            return result;
        }

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;

 

 

 

 

 

 

 

posted @ 2014-04-03 17:00  zyip  阅读(324)  评论(0编辑  收藏  举报