Notiz
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Iech unzemellen oder Verzeechnesser ze änneren.
Zougrëff op dës Säit erfuerdert Autorisatioun. Dir kënnt probéieren, Verzeechnesser ze änneren.
Implicitly-typed variables cannot have multiple declarators.
Multiple declarators are allowed in explicit type declarations, but not with implicitly typed variables.
To correct this error
There are three options:
- If the variables are of the same type, use explicit declarations.
- Declare and assign a value to each implicitly typed local variable on a separate line.
- Declare a variable using Tuple deconstruction syntax. Note: this option will not work inside a
using
statement asTuple
does not implementIDisposable
.
Example 1
The following code generates CS0819:
// cs0819.cs
class Program
{
public static void Main()
{
var a = 3, b = 2; // CS0819
// First correction option.
//int a = 3, b = 2;
// Second correction option.
//var a = 3;
//var b = 2;
// Third correction option.
//var (a, b) = (3, 2);
}
}
Example 2
The following code generates CS0819:
// cs0819.cs
class Program
{
public static void Main()
{
using (var font1 = new Font("Arial", 10.0f),
font2 = new Font("Arial", 10.0f)) // CS0819
{
}
// First correction option.
//using (Font font1 = new Font("Arial", 10.0f),
// font2 = new Font("Arial", 10.0f))
//{
//}
// Second correction option.
//using (var font1 = new Font("Arial", 10.0f)
//{
// using (var font2 = new Font("Arial", 10.0f)
// {
// }
//}
}
}
See also
Schafft mat eis op GitHub zesummen
D'Quell fir dësen Inhalt kann op GitHub fonnt ginn, wou Dir och Theeme schafen an iwwerpréiwen kënnt an Ufroen unhuele kënnt. Fir méi Informatiounen, gitt op eisen Auteur-Guide.