'identifier' 이름이 현재 컨텍스트에 없습니다.
클래스, 네임스페이스 또는 범위에 없는 이름을 사용하려고 했습니다. 이름의 철자를 확인하고 지시문 및 어셈블리 참조를 확인 using 하여 사용하려는 이름을 사용할 수 있는지 확인합니다.
이 오류는 다음 예제와 같이 루프나 try 또는 if 블록에 변수를 선언한 다음 바깥쪽 코드 블록이나 별도의 코드 블록에서 해당 변수에 액세스하려고 하는 경우 발생합니다.
참고
식 람다에서 => 연산자의 greater than 기호가 누락된 경우에도 이 오류가 표시될 수 있습니다. 자세한 내용은 식 람다를 참조하세요.
using System;
class MyClass1
{
public static void Main()
{
try
{
// The following declaration is only available inside the try block.
var conn = new MyClass1();
}
catch (Exception e)
{
// The following expression causes error CS0103, because variable
// conn only exists in the try block.
if (conn != null)
Console.WriteLine("{0}", e);
}
}
}
다음 예제에서는 이 오류를 해결합니다.
using System;
class MyClass2
{
public static void Main()
{
// To resolve the error in the example, the first step is to
// move the declaration of conn out of the try block. The following
// declaration is available throughout the Main method.
MyClass2 conn = null;
try
{
// Inside the try block, use the conn variable that you declared
// previously.
conn = new MyClass2();
}
catch (Exception e)
{
// The following expression no longer causes an error, because
// the declaration of conn is in scope.
if (conn != null)
Console.WriteLine("{0}", e);
}
}
}
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET