Avviso del compilatore (livello 4) CS0649

Aggiornamento: novembre 2007

Messaggio di errore

Impossibile assegnare un valore diverso al campo 'campo'. Il valore predefinito è 'valore'.
Field 'field' is never assigned to, and will always have its default value 'value'

Il compilatore ha rilevato una dichiarazione di un campo interno o privato non inizializzato a cui non viene mai assegnato un valore.

Il seguente codice di esempio genera l'avviso CS0649:

// 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()
   {
   }
}