Compilerwarnung (Stufe 4) CS0649

Aktualisiert: November 2007

Fehlermeldung

Dem Feld "Feld" wird nie etwas zugewiesen, und es hat immer seinen Standardwert von "Wert".
Field 'field' is never assigned to, and will always have its default value 'value'

Der Compiler hat eine nicht initialisierte, private oder interne Felddeklaration entdeckt, der nie Werte zugewiesen werden.

Im folgenden Beispiel wird CS0649 generiert:

// CS0649.cs
// compile with: /W:4
using System.Collections;

class MyClass
{
   Hashtable table;  // CS0649
   // You may have intended to initialize the variable to null
   // Hashtable table = null;

   // Or you may have meant to create an object here
   // Hashtable table = new Hashtable();

   public void Func(object o, string p)
   {
      // Or here
      // table = new Hashtable();
      table[p] = o;
   }

   public static void Main()
   {
   }
}