Setting a variable name as a type

Total Post:108


 1331  View(s)
Rate this:

I am deserializing a json object from a third party API. One of the Objects properties is a variable called "checked". In 'checked' is a type. Is there anyway to overcome this.

Im using Newtonsoft to do the deserializing.

Nothing special about the class,

public class item{

  public bool checked;


  1. Re: Setting a variable name as a type

    Hi John,

    While @nemesv's answer is correct and will work fine, I just wanted to mention that there is another alternative if you are using Json.Net. You could use a JsonProperty attribute to map your class property to the JSON property such that they can have different names.

    For example:

    public class item
        public bool IsChecked { get; set; }

      Modified On Apr-04-2018 12:43:00 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.