Compiler Warning (level 3) CS0168
The variable 'var' is declared but never used
The compiler issues a level-three warning when you declare a variable, but do not use it.
The following sample generates a CS0168 warning:
C#
// CS0168.cs
// compile with: /W:3
public class clx
{
public int i;
}
public class clz
{
public static void Main() {
clx a; // CS0168, the variable 'a' is declared but never used
// try the following line instead
// clx a = new clx(); // this does not generate a warning because the clx constructor must execute.
}
}
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: