Share via


컴파일러 오류 CS1545

업데이트: 2007년 11월

오류 메시지

'property' 속성, 인덱서 또는 이벤트는 이 언어에서 지원되지 않습니다. 'set accessor' 또는 'get accessor' 접근자 메서드를 직접 호출해 보십시오.
Property, indexer, or event 'property' is not supported by the language; try directly calling accessor methods 'set accessor' or 'get accessor'

기본이 아닌 인덱서가 있는 개체를 사용하고 있는 코드에서 인덱싱된 구문을 사용하려고 했습니다. 이 오류를 해결하려면 속성의 get 또는 set 접근자 메서드를 호출하십시오.

예제

// CPP1545.cpp
// compile with: /clr /LD
// a Visual C++ program
using namespace System;
public ref struct Employee {
   Employee( String^ s, int d ) {}

   property String^ name {
      String^ get() {
         return nullptr;
      }
   }
};

public ref struct Manager {
   property Employee^ Report [String^] {
      Employee^ get(String^ s) {
         return nullptr;
      }

      void set(String^ s, Employee^ e) {}
   }
};

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

// CS1545.cs
// compile with: /r:CPP1545.dll

class x {
   public static void Main() {
      Manager Ed = new Manager();
      Employee Bob = new Employee("Bob Smith", 12);
      Ed.Report[ Bob.name ] = Bob;   // CS1545
      Ed.set_Report( Bob.name, Bob);   // OK
   }
}