0

When trying to create enum list of tabs name, got the "Identifier expected" error (see attached).

What am i doing wrong?enum list

5
  • 1
    It would be awesome if you could provide a minimal reproducible example (in text of your question, not as an external link). Commented Apr 5, 2018 at 8:14
  • 6
    value can not start with number (2ndOffers is invalid value) Commented Apr 5, 2018 at 8:14
  • The problem is your 2ndOffers enum value, you cannot start an identifier with a digit. It has to be an underscore or a letter. Try using SecondOffers instead. Commented Apr 5, 2018 at 8:16
  • Possible duplicate of C# using numbers in an enum Commented Apr 5, 2018 at 8:19
  • Thanks all, it sure did solved the problem Commented Apr 5, 2018 at 8:34

2 Answers 2

3

The problem is that 2ndOffers is not an identifier.

An identifier has to start with an underscore or a letter, it can contain digits, after that initial character.

So rewrite that identifier to be SecondOffers instead.

A technical version of the specification can be found here: Lexical structure - Identifiers which contains this part:

identifier_or_keyword
    : identifier_start_character identifier_part_character*
    ;

identifier_start_character
    : letter_character
    | '_'
    ;

identifier_part_character
    : letter_character
    | decimal_digit_character
    | connecting_character
    | combining_character
    | formatting_character
    ;

Basically, it has to start with "identifier_start_character" and can continue with zero or more "identifier_part_character", and "identifier_start_character" can only be a letter or an underscore.

Sign up to request clarification or add additional context in comments.

Comments

0

You can't start an identifier with a number in C# like

2ndOffers

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.