컴파일러 오류 CS0646
업데이트: 2007년 11월
오류 메시지
인덱서를 포함하는 형식에 DefaultMember 특성을 지정할 수 없습니다.
Cannot specify the DefaultMember attribute on a type containing an indexer
클래스나 다른 형식에서 System.Reflection.DefaultMemberAttribute를 지정하면 인덱서를 포함할 수 없습니다. 자세한 내용은 속성을 참조하십시오.
다음 샘플에서는 CS0646 오류가 발생하는 경우를 보여 줍니다.
// CS0646.cs
// compile with: /target:library
[System.Reflection.DefaultMemberAttribute("x")] // CS0646
class MyClass
{
public int this[int index] // an indexer
{
get
{
return 0;
}
}
public int x = 0;
}
// OK
[System.Reflection.DefaultMemberAttribute("x")]
class MyClass2
{
public int prop
{
get
{
return 0;
}
}
public int x = 0;
}
class MyClass3
{
public int this[int index] // an indexer
{
get
{
return 0;
}
}
public int x = 0;
}