To declare a char value in C# we just surround the character with single quotes: 'x'
.
But what is the "clearest" way to declare a char value that is a single quote/apostrophe?
I've ended up using "'"[0]
, though I had expected ''''
to work (on the basis that ""
can be used to delimit a quote character within a string.
Is there a sensible, more succinct option?
They are two entirely different punctuation symbols. Single quotes are limited to one real function in written U.S. English, which is to indicate a quotation within a quotation. Apostrophes, on the other hand, are used to denote possessive form and to indicate omission.
Single quotes are for single characters whereas double quotes are used to create string literals.
These are ASCII code 0x22 for double quotation mark, and ASCII code 0x27 for single quotation mark.
You can escape the quote with a backslash: '\''
You can also use '\''
or (char)39
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With