Compiler Error CS1519
Collapse the table of content
Expand the table of content

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:

© 2015 Microsoft