Compiler Error CS1519

Invalid token 'token' in class, struct, or interface member declaration

This error is generated whenever a token is encountered in a location where it does not belong. A token is a keyword; an identifier (the name of a class, struct, method, and so on); a string, character, or numeric literal value such as 108, "Hello", or 'A'; or an operator or punctuator such as == or ;.

Any class, struct, or interface member declaration that contains invalid modifiers before the type will generate this error. To fix the error, remove the invalid modifiers.

The following sample generates CS1519 in five places because tokens are placed in locations where they are not valid:

// CS1519.cs
// Generates CS1519 because a class name cannot be a number:
class Test 42 
{
// Generates CS1519 because of 'j' following 'I'
// with no comma between them:
    int i j; 
// Generates CS1519 because of "checked" on void method:
    checked void f4();   
   
// Generates CS1519 because of "num":
    void f5(int a num){}      

// Generates CS1519 because of namespace inside class:
    namespace;           

}

See Also

Reference

Classes (C# Programming Guide)

Structs (C# Programming Guide)

Interfaces (C# Programming Guide)

Methods (C# Programming Guide)

Change History

Date

History

Reason

October 2008

Added explanatory comments to code example.

Customer feedback.