I need to create a class where one property name should be return , but when I create a property name like return , I get an error.
After some research, it turned out that you can use the reserved keyword as the name of a property or variable by adding the @ prefix in C # or by including it in square brackets [] in VB.NET. For example:
var @class = new object();
So here is my class design code.
public class Person { string _retVal; public string @return { get { return _retVal; } set { _retVal = value; } } } ... Person p = new Person(); p.@return = "hello";
Now I am not getting any errors, but when I try to access the property name, for example return , then I need to write a name like @return , which I do not want. I want to access the property name, for example p.return = "hello"; instead of p.@return = "hello"; so I would like to know if there is a way to do this?
Thomas
source share