컴파일러 오류 CS0199
업데이트: 2007년 11월
오류 메시지
정적 읽기 전용 필드 'name'의 필드는 ref 또는 out으로 전달할 수 없습니다. 단 정적 생성자에서는 예외입니다.
Fields of static readonly field 'name' cannot be passed ref or out (except in a static constructor)
생성자의 readonly 변수를 ref 또는 out 매개 변수로 전달하려는 경우, 이 변수는 해당 생성자와 동일하게 static을 사용해야 합니다. 자세한 내용은 매개 변수 전달(C# 프로그래밍 가이드)을 참조하십시오.
예제
다음 샘플에서는 CS0199 오류가 발생하는 경우를 보여 줍니다.
// CS0199.cs
class MyClass
{
public static readonly int TestInt = 6;
static void TestMethod(ref int testInt)
{
testInt = 0;
}
MyClass()
{
TestMethod(ref TestInt); // CS0199, TestInt is static
}
public static void Main()
{
}
}