Partager via


Avertissement du compilateur (niveau 4) CS0649

Mise à jour : novembre 2007

Message d'erreur

Le champ 'champ' n'est jamais assigné et possédera toujours sa valeur par défaut 'valeur'
Field 'field' is never assigned to, and will always have its default value 'value'

Le compilateur a détecté une déclaration de champ non initialisée privée ou interne, à laquelle aucune valeur n'est assignée.

L'exemple suivant génère l'avertissement 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()
   {
   }
}