This documentation is archived and is not being maintained.

Compiler Error CS1012

Too many characters in character literal

An attempt was made to initialize a char constant with more than one character.

CS1012 can also occur when doing data binding. For example the following line will give an error:

<%# DataBinder.Eval(Container.DataItem, 'doctitle') %>

Try the following line instead:

<%# DataBinder.Eval(Container.DataItem, "doctitle") %>

The following sample generates CS1012:

// CS1012.cs
class Sample
   static void Main()
      char a = 'xx';   // CS1012
      char a2 = 'x';   // OK