简体   繁体   English

我可以在动态中使用字符串吗?

[英]Can I use a string in-line with a dynamic?

I have the following code to collect a value from a json object using dynamic.我有以下代码使用动态从 json 对象收集值。

var valueOne = jsonObj.features[0].properties.POLYGON_NM.ToString();

I would like to grab other values as well, without manually typing every option.我也想获取其他值,而无需手动输入每个选项。

var valueTwo = jsonObj.features[0].properties.[TEXTBOX_VALUE].ToString();

Is this possible using Dynamics?这可以使用 Dynamics 吗?

you can use JObject for this senario.你可以在这个场景中使用 JObject。

        JObject j = JObject.Parse("your json");
        var valueTwo = j["TEXTBOX_VALUE"];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可以将[CustomAttribute]与匿名内联代理一起使用吗? - Can one use [CustomAttribute] with anonymous in-line delegates? 如何从文本阅读器中剥离嵌入式注释 - How can I strip in-line comments from a text reader 有没有更好的方法将动态输入内联传递给 DataTestMethod? 即如何以编程方式为数据驱动测试创建测试输入 - Is there a better way to pass dynamic inputs in-line to a DataTestMethod? I.e. How to programmatically create test inputs for a data-driven test 如何在Web窗体的嵌入式if-else语句中使用从数据绑定表达式解析的值? - how do I use the value resolved from a Data-Binding expression in an in-line if-else statement in Web Forms? 设定值在线 - Setting value in-line C#字符串串联-内联与逐行 - C# string concatenation - in-line vs. line-by-line 如何使用 Roslyn 查找调用方法的参数是变量(通过“var/string”)还是内联字符串 - How to find if a parameter to an invoked method is a variable (via "var/string") or an in-line string using Roslyn 在线显示ValidationResult错误 - Show ValidationResult errors in-line 如何使用Linq根据字符串中的换行符创建IEnumerable? - How can I use Linq to create an IEnumerable based on line breaks in a string? 如何将LINQ与dynamic一起使用? 泛型? - How can I use LINQ with dynamic? Generics?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM