C# C# Basics (Retired) Console I/O Say Hello!

Are single quotes a valid for of signifying text in C#?

The quiz doesn't accept the single quotes which I placed the first time and I wondered if single quotes were valid in their place.

1 Answer

Steven Parker
Steven Parker
207,597 Points

:point_right: There are some languages (like JavaScript and Python) which use more than one token to indicate strings, but in C# only the normal quote character (") is used to indicate a string.

The apostrophe (a.k.a "single quote") is used in C# to indicate single characters:

string s = "This is a string";
char c = 'x';  // this is a single character