I'm using a List<Test> model with two entries and using "A" and "B" for the operator value. It does show AB on my view. This is really MVC or WebPages? Not sure what could make the difference it still fails on your side and which the same error message.
Edit:
publicstring@operator{get;set;}
I am also able to modified my class to use _operator
No, @operator is how to name a property operator despite being a C# keyword. From the link I posted earlier :
"Keywords are predefined, reserved identifiers that have special meanings to the compiler.
They cannot be used as identifiers in your program unless they include @ as a prefix. For example, @if is a valid identifier, but if is
not because if is a keyword."
AFAIK this is just part of the syntax if using System.Reflection you should see the property name is really just "operator".
All-Star
48510 Points
18072 Posts
Re: Identifier expected; 'operator' is a keyword
May 27, 2020 02:34 PM|PatriceSc|LINK
Could you confirm you tried :
I'm using a List<Test> model with two entries and using "A" and "B" for the operator value. It does show AB on my view. This is really MVC or WebPages? Not sure what could make the difference it still fails on your side and which the same error message.
Edit:
No, @operator is how to name a property operator despite being a C# keyword. From the link I posted earlier :
"Keywords are predefined, reserved identifiers that have special meanings to the compiler. They cannot be used as identifiers in your program unless they include
@
as a prefix. For example,@if
is a valid identifier, butif
is not becauseif
is a keyword."AFAIK this is just part of the syntax if using System.Reflection you should see the property name is really just "operator".