상위 질문
타임라인
채팅
관점

인덱서 (프로그래밍)

위키백과, 무료 백과사전

Remove ads

인덱서(indexer)는 객체 지향 프로그래밍에서 특정 클래스나 구조체의 인스턴스가 배열과 같이 인덱싱될 수 있게 한다.[1] 연산자 오버로딩의 일종이다.

예시

인덱서를 클래스에 사용한 C#의 예는 다음과 같다:[2]

class OurFamily
{
private long[] familyMember = new long[7];
  public long this [int index]
  {
    // The get accessor
    get
    {
      return familyMember[index];
    }

    // The set accessor with
    set
    {
      familyMember[index] = value;
    }
  }
}

같이 보기

각주

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads