.NET 4中:如何引用名为QUOT性和动态对象;回归" [英] .Net 4: How to reference a dynamic object with property named "return"

查看:152
本文介绍了.NET 4中:如何引用名为QUOT性和动态对象;回归"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从一个公共API获取JSON并将其转换成使用JsonFx动态对象。

  JsonFx.Json.JsonReader读卡器=新JsonFx.Json.JsonReader();
动态响应= reader.Read(jsonAsString);
 

该JSON包含一个名为归还财产。例如,

<$p$p><$c$c>{"result":"success","return":{"high":{"value":"3.85001","value_int":"385001","display":"3.85001\u00a0\u20ac","currency":"EUR"}}

JsonFx创建动态对象不错,我也可以调试,并观察值。 问题是,当我尝试引用的财产在我的code编译器会抱怨:

  response.return.high.currency
标识预期; 回归是一个关键词
 

我如何可以参考返回属性不会编译器抱怨?

解决方案

尝试响应。@ return.high.currency

您需要追加 @ 在任何领域至极的名字开始时是一样的C#的关键字。

I'm retrieving json from a public api and converting it into a dynamic object using JsonFx.

JsonFx.Json.JsonReader reader = new JsonFx.Json.JsonReader();
dynamic response = reader.Read(jsonAsString);

The json contains a property named return. e.g.

{"result":"success","return":{"high":{"value":"3.85001","value_int":"385001","display":"3.85001\u00a0\u20ac","currency":"EUR"}}

JsonFx creates the dynamic object fine and I can also debug into it and see the values. The problem is when I try to reference the property in my code the compiler complains:

response.return.high.currency
Identifier expected; 'return' is a keyword  

How can I reference the return property without the compiler complaining?

解决方案

Try response.@return.high.currency.

You need to append @ at the begining of any field wich name is the same as C# keywords.

这篇关于.NET 4中:如何引用名为QUOT性和动态对象;回归&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆