c# - Using standard or custom date formats -
the following code:
datetime test = new datetime(); console.writeline(test.tostring("d")); console.writeline(test.tostring("d_")); console.writeline(test.tostring("dd"));
produces following results:
0001-01-01 1_ 01
the first result full date, because d
being treated standard date format. on other hand, d_
treated custom date format , in such case d treated short day string. there way generate short day without underscore?
any of these:
console.writeline(test.tostring("%d")); console.writeline(test.tostring(" d")); console.writeline(test.tostring("d "));
from https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx#usingsinglespecifiers
to use of custom date , time format specifiers specifier in format string (that is, use "d", "f", "f", "g", "h", "h", "k", "m", "m", "s", "t", "y", "z", ":", or "/" custom format specifier itself), include space before or after specifier, or include percent ("%") format specifier before single custom date , time specifier.
Comments
Post a Comment