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:
C#
// CS1012.cs
class Sample
{
static void Main()
{
char a = 'xx'; // CS1012
char a2 = 'x'; // OK
System.Console.WriteLine(a2);
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: