Microsoft KB Archive/814824

= BUG: You receive a &quot;CS1519&quot; compiler error code when you use surrogate characters as a token in Visual C# .NET =

Article ID: 814824

Article Last Modified on 11/14/2007

-

APPLIES TO


 * Microsoft Visual C# .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# 2005 Express Edition

-



SYMPTOMS
When you compile Visual C# .NET or Visual C# 2005 code with surrogate Unicode characters as a token name, you may receive the following CS1519 compiler error message:

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



CAUSE
Visual C# .NET or Visual C# 2005 only accepts alphabetical and numeric characters in a token name.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
A surrogate pair is a coded character representation for a single abstract character is made up of a sequence of two code units. The first unit of the pair is a high-surrogate (U+D800 through U+DBFF) and the second is a low-surrogate (U+DC00 through U+DFFF).

The Visual C# .NET or Visual C# 2005 compiler does not support surrogate Unicode characters as a token name.

Steps to Reproduce the Behavior
  Start Notepad, and then paste the following code: using System; using System.Threading; using System.Globalization;

namespace application1 {    class SurrogateTest {       public static string \u20105 {         return &quot;\u20105&quot;; }       public static void Main(String[] args) {         Console.WriteLine (&quot;Function return: {0}&quot;, \u20105); }   } }  Save the file as Surrogate_Unicode_test.cs . Open a Visual Studio .NET 2002 command prompt or Visual Studio 2005 command prompt. Type csc Surrogate_Unicode_test.cs to compile the file. You may receive the error message that is described in the &quot;Symptoms&quot; section of this article.

<div class="references_section">