컴파일러 오류 CS1009

인식할 수 없는 이스케이프 시퀀스입니다.

string의 백슬래시(\) 뒤에 예기치 않은 문자가 있습니다. 컴파일러에 올바른 이스케이프 문자 중 하나가 필요합니다. 자세한 내용은 문자 이스케이프를 참조하십시오.

다음 샘플에서는 CS1009 오류가 발생하는 경우를 보여 줍니다.

// CS1009-a.cs
class MyClass
{
   static void Main()
   {
      string a = "\m";   // CS1009
      // try the following line instead
      // string a = "\t";
   }
}

이 오류는 일반적으로 파일 이름에 백슬래시를 사용할 경우 발생합니다. 예를 들면 다음과 같습니다.

string filename = "c:\myFolder\myFile.txt";

이 오류를 해결하려면 다음 예제에서와 같이 "\\"를 사용하거나 따옴표 앞에 @가 있는 문자열 리터럴을 사용하십시오.

// CS1009-b.cs
class MyClass
{
   static void Main()
   {
      string filename = "c:\myFolder\myFile.txt";   // CS1009
      // try the one of the following lines instead
      // string filename = "c:\\myFolder\\myFile.txt";
      // string filename = @"c:\myFolder\myFile.txt";
   }
}