Share via


컴파일러 오류 CS0027

업데이트: 2007년 11월

오류 메시지

현재 컨텍스트에 'this' 키워드를 사용할 수 없습니다.
Keyword 'this' is not available in the current context

this(C# 참조) 키워드를 속성, 메서드 또는 생성자 외부에서 찾을 수 없습니다.

이 오류를 해결하려면 문을 수정하여 사용된 this 키워드를 제거하거나 속성, 메서드 또는 생성자 내부에서 문의 일부 또는 전체를 이동합니다.

다음 예제에서는 CS0027 오류가 발생하는 경우를 보여 줍니다.

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication3
{
    class MyClass
    {

        int err1 = this.Fun() + 1;  // CS0027 

        public int Fun()
        {
            return 10;
        }

        public void Test()
        {
            // valid use of this
            int err = this.Fun() + 1;
            Console.WriteLine(err);
        }

        public static void Main()
        {
            MyClass c = new MyClass();
            c.Test();
        }
    }
}