Can you please tell, how can I access value of my dynamic variable in C#.NET.
dynamic response = api.createSession(order.Tables[0].Rows[i]["sessionid"].ToString(),
"description=" + description +
"&organization=" + organization +
"&allowUpload=" + allowUpload +
"&singleSignOnOnly=" + singleSignOnOnly +
"&maxUserCount=" + maxUserCount);
In above, "response" is dynamic variable and need to access its value. I have tried following..
string[] myStringArray = new string[50];
myStringArray[0] = response[2]["Value"];
Thanks in advance..
What exactly do you mean by "its value" here? Basically, the "value" of a dynamic
variable/field is simply a reference to an object. What is interesting is: what does that object provide ? Well, we can't tell you that, because we don't know what api.createSession
returns. But it it notionally exposed, say, an Id
and a Name
- then you would just use:
int id = response.Id;
string name = response.Name;
Of course, it is also possible that the object referenced by response
exposes methods, for example:
response.Foo();
We can't tell you. And since it is dynamic
, the compiler can't tell you. The only thing that can tell you is the documentation of api.createSession
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.