Question

How do I declare backslash constant character in C#?

char Character_BACKSLASH = '\';

Thank you!

Rune

Était-ce utile?

La solution

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

Autres conseils

char Character_BACKSLASH = '\\';

You need to escape your backslash literal:

const char BACKSLASH = '\\';

Or use the built-in value:

Path.DirectorySeparatorChar
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top