Compilerwarnung (Stufe 3) CS0168

Die Variable „var“ ist deklariert, wird aber nie verwendet

Der Compiler gibt eine Warnung der Ebene 3 aus, wenn Sie eine Variable deklarieren und zuweisen, aber nicht verwenden.

Im folgenden Beispiel wird eine CS0168-Warnung generiert:

// 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.
    }
}