Quote direct speech in single quote marks. Single quotation marks are also known as 'quote marks', 'quotes', 'speech marks' or 'inverted commas'. Use them to: show direct speech and the quoted work of other writers. enclose the title of certain works.
To place quotation marks in a string in your code In Visual C# and Visual C++, insert the escape sequence \" as an embedded quotation mark.
When we place \' escape sequence in printf, it has a special meaning. printf will print ' (single quote) instead \'.
In C# it is not allowed to enclose a string in single quotes in any version of . NET.
It's a literal string delimiter.
Anything between the single quotes is interpreted as a literal character, and will not be interpreted as a custom format string.
They are equivalent to escaping using a backslash: dd'T'HH
is the same as dd\THH
.
In your string yyyy'-'MM'-'dd'T'HH':'mm':'ss
, the quotes are unnecessary around the -
and T
, as those are not custom format strings, and so will always be interpreted as string literals. However :
is a format specifier, which evaluates to a time separator that's suitable for the current culture. Quoting it as ':'
means that the literal character :
will always be used, regardless of the current culture.
It's useful to know that this is the same format used by the Windows GetDateFormat function. You use apostrophe's to indicate some literal you want inserted into the resulting string.
More documentation of the string formatting codes can be found on:
In your string it is indiating that it literally wants to add hyphens, colons, and the T characters:
yyyy
'-'
MM'-'
dd'T'
HH':'
mm':'
ss
In general you don't want to construct dates/times with literally a hyphens (-
) or colons (:
), or even slashes (/
). Because those are wrong for cultures that don't use slashes and colons to construct dates/times:
What you would want to do, if you want to indicate:
Is use the special:
And construct a format such as:
dd/yyyy/MM ss:HH:mm
I don't know what business need one might have to show a date as:
But this way the localizer will insert the culture's correct date and time separators.
Whereas if you literally asked for /
, -
, or :
:
'/'
yyyy '/'
MM ss ':'
HH ':'
mmYou will literally get:
rather than:
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