Compiler Error CS0819

Implicitly typed locals cannot have multiple declarators.

Multiple declarators are allowed in explicit type declarations, but not with implicitly typed variables.

To correct this error

  • Declare and assign a value to each implicitly typed local variable on a separate line.

Example

The following code generates CS0819:

// cs0819.cs
class A
{
    public static int Main()
    {
        var a = 3, b = 2; // CS0819
        return -1;
    }
}

See Also

Reference

Implicitly Typed Local Variables (C# Programming Guide)