C# return dynamic/anonymous type value as function result

1467 단어 function

 
 
 
 
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;

 
 
 
 
 
 

좋은 웹페이지 즐겨찾기