如何使用关键字作为属性名称? [英] How can I use a keyword as a property name?

查看:100
本文介绍了如何使用关键字作为属性名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经非常成功地将匿名类型序列化为json.

I have been serializing anonymous types into json quite successfully until now..

        dynamic jsObject;

        jsObject = new ExpandoObject();
        jsObject.dataUrl = Controller.Url.Action("loadall", "residuals", new { EditionId = EditionId, Country = Country, ModelYear = ModelYear, MakeId = ModelId, StyleId = style.Id });
        jsObject.id = style.Id;
        jsObject.text = style.Name;
        jsObject.iconCls = "sprite-toolbar-flag-us";
        jsObject.checked = false; // <---<< the problem is here
        jsObject.leaf = true;
        jsObject.IsCustomQuote = style.IsCustomQuote;

        return jsObject;

有解决方法吗?如果没有的话,我将尝试将字典序列化为json对象.

Is there a workaround? I'm gonna try to serialize a dictionary into a json object if not..

推荐答案

您将使用"verbatim"运算符@:jsObject.@checked = false;

You would use the "verbatim" operator @: jsObject.@checked = false;

这篇关于如何使用关键字作为属性名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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