I want to read last two digits of year
So I tried like below...but it is not working...
Can any one Tell ... why this code does not work
sResolvedDateTimePart =String .Format( "{0,2:D2}" , DateTime.Now.Year);
The precision and alignment specifiers (2 in your example) indicate the *minimum* number of
digits required in the output. They do not specify the *maximum* number of digits. When you
specify 2 you are saying the output should have *at least* 2 digits. But it may have more,
and will have more if the value being formatted is more than 2 digits long. These specifiers
never cause *truncation* of the value being formatted, which is what you appear to have been
expecting.
- Wayne
No comments:
Post a Comment