This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge

Invalid expression term 'character'

The compiler detected an invalid character in an expression.

The following sample generates CS1525:

// CS1525.cs  
class x  
   public static void Main()  
      int i = 0;  
      i = i +   // OK - identifier  
      'c' +     // OK - character  
      (5) +     // OK - parenthesis  
      [ +       // CS1525, operator not a valid expression element  
      throw +   // CS1525, keyword not allowed in expression  
      void;     // CS1525, void not allowed in expression  

An empty label can also generate CS1525, as in the following sample:

// CS1525b.cs  
using System;  
public class MyClass  
   public static void Main()  
      goto FoundIt;  
      FoundIt:      // CS1525  
      // Uncomment the following line to resolve:  
      // System.Console.Write("Hello");