컴파일러 경고(수준 4) CS0649

업데이트: 2007년 11월

오류 메시지

'field' 필드에는 할당되지 않으므로 항상 'value' 기본값을 사용합니다.
Field 'field' is never assigned to, and will always have its default value 'value'

컴파일러에서 초기화되지 않은 전용 또는 내부 필드 선언을 찾았습니다. 이 필드에는 값을 할당할 수 없습니다.

다음 샘플에서는 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()
   {
   }
}