다음을 통해 공유


방법: 인터페이스 구현

이 프로시저를 사용하여 인터페이스 구현이라는 IntelliSense 작업을 수행할 수 있습니다. 자세한 내용은 인터페이스 구현을 참조하십시오.

IntelliSense를 사용하여 명시적 선언으로 C#에서 인터페이스를 구현하려면

  1. 콘솔 응용 프로그램을 만듭니다.

  2. class Program 선언 뒤에 커서를 놓습니다.

  3. 선언이 class Program : IComparable이 되도록 : IComparable을 입력합니다.

  4. IComparable 아래의 스마트 태그를 활성화합니다. 다음 두 가지 옵션이 나타납니다.

    • 'IComparable' 인터페이스 구현

    • 'IComparable' 인터페이스를 명시적으로 구현

  5. 'IComparable' 인터페이스를 명시적으로 구현을 선택합니다.

IntelliSense는 IComparable 인터페이스의 IComparable.CompareTo 메서드를 Program 클래스에 추가합니다.

   #region IComparable Members
   int IComparable.CompareTo(object obj)
   {
      throw new Exception("The method or operation is not implemented.");
   }
   #endregion

IntelliSense를 사용하여 암시적 선언으로 C#에서 인터페이스를 구현하려면

  1. 콘솔 응용 프로그램을 만듭니다.

  2. class Program 선언 뒤에 커서를 놓습니다.

  3. 선언이 class Program : IComparable이 되도록 : IComparable을 입력합니다.

  4. IComparable 아래의 스마트 태그를 활성화합니다. 다음 두 가지 옵션이 나타납니다.

    • 'IComparable' 인터페이스 구현

    • 'IComparable' 인터페이스를 명시적으로 구현

  5. 'IComparable' 인터페이스 구현을 선택합니다.

IntelliSense는 IComparable 인터페이스의 CompareTo 메서드를 Program 클래스에 추가합니다.

   #region IComparable Members
   public int CompareTo(object obj)
   {
      throw new Exception("The method or operation is not implemented.");
   }
   #endregion

참고 항목

참조

인터페이스 구현

인터페이스(C# 프로그래밍 가이드)

명시적 인터페이스 구현(C# 프로그래밍 가이드)

기타 리소스

자동 코드 생성