Reputation: 31
Is it somehow possible to call a C# variable return
?
I need to deserialize JSON data and there is a field called return
.
And I am unable to create class with this name to create object for deserialization :-/
Thank you.
Upvotes: 3
Views: 933
Reputation: 44449
Either use @return
or simply annotate it (JSON.NET):
[JsonProperty(PropertyName = "return")]
public string MyPropertyName {get; set;}
Upvotes: 4
Reputation: 1885
Try prefixing the variable name with '@'. http://msdn.microsoft.com/en-us/library/aa664670%28v=vs.71%29.aspx
Upvotes: 1
Reputation: 354576
You can use keywords as identifiers by prefixing them with @
:
public int Foo()
{
int @return = 5;
return @return;
}
Note that this is not necessary for the so-called contextual keywords, such as LINQ operators, var
and others that came later. Those have special rules where they can appear which allow them to be used as identifiers.
Upvotes: 3