我正在尝试从 System.Web.Helpers.DynamicJsonObject 中读取值。我可以在调试器中看到这些值,但不知道如何访问它们。这个我试过了
item.GetType().GetProperty("batch_id").GetValue(item, null);
但是当我尝试在调试器中得到这个响应时“item.GetType().GetProperty("batch_id")' is null"
我附上了我的解决方案的图片
谢谢, -测试
最佳答案
它是动态的,所以你可以这样做:
string batchId = item.batch_id;
如果出于某种原因您在 string
中有属性名称,并且在编译时不知道它,索引运算符将起作用:
string value = item["batch_id"];
关于c# - 从动态对象 C# 中读取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12922746/