creitz
creitz

Reputation: 31

how to deserialize "ref" parameter

I'm trying to parse a json file that contains a parameter named ref. I'm deserializing into a class structure:

public class JiveContentObject
{
   public int id { get; set;}
   public string subject { get; set;}
   ..etc
}

however, I can't exactly write public string ref {get; set;} since ref is a keyword in c#. Is there any way I can work around this?

Upvotes: 3

Views: 161

Answers (1)

Servy
Servy

Reputation: 203827

Prefix the identifier with @:

public class JiveContentObject
{
    public int id { get; set; }
    public string subject { get; set; }
    public string @ref { get; set; }
}

This is exactly what it's there for.

Upvotes: 7

Related Questions