문제

How do I declare backslash constant character in C#?

char Character_BACKSLASH = '\';

Thank you!

Rune

도움이 되었습니까?

해결책

From Lexical structure

A character that follows a backslash character (\) in a character must be one of the following characters: ', ", \, 0, a, b, f, n, r, t, u, U, x, v. Otherwise, a compile-time error occurs.

So you just need to use;

char Character_BACKSLASH = '\\';

enter image description here

다른 팁

char Character_BACKSLASH = '\\';

You need to escape your backslash literal:

const char BACKSLASH = '\\';

Or use the built-in value:

Path.DirectorySeparatorChar
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top