Share via


컴파일러 오류 CS0171

업데이트: 2007년 11월

오류 메시지

제어를 호출자에게 반환하려면 자동으로 구현된 'name' 속성의 지원 필드가 완전히 할당되어야 합니다. 생성자 이니셜라이저에서 기본 생성자를 호출하십시오.
Backing field for automatically implemented property 'name' must be fully assigned before control is returned to the caller. Consider calling the default constructor from a constructor initializer.

구조체 안에 있는 생성자는 구조체 안의 모든 필드를 초기화해야 합니다. 자세한 내용은 생성자(C# 프로그래밍 가이드)를 참조하십시오.

다음 샘플에서는 CS0171 오류가 발생하는 경우를 보여 줍니다.

// CS0171.cs
struct MyStruct
{
   MyStruct(int initField)   // CS0171
   {
      // i = initField;      // uncomment this line to resolve this error
   }
   public int i;
}

class MyClass
{
   public static void Main()
   {
      MyStruct aStruct = new MyStruct();
   }
}