1. Const, READONLY, static
- The Const-Modified field representation is a constant, which is essentially compiled and the actual value of its field is written in the DLL before execution. You can change the value only when you declare it.
- ReadOnly is read-only and can be modified only at the time of Declaration and in the constructor. The compiled code can be seen, in fact, in the constructor to assign values in the
- Static, modified in one place, is valid for all objects. It uses the class name. Word by Access.
- The Static ReadOnly is valid and read-only for all objects. It uses the object. Word by Access. Note: Unlike ReadOnly, it is only possible to assign values at the time of declaration and in the static constructor.
2. Time string formatting
A day in the D month. One-digit date has no leading zeros.
DD a day of the month. A one-digit date has a leading zero.
M-month number. One-digit month has no leading zeros.
MM month number. One-digit month has a leading zero.
The YYYY includes the four-digit year of the era.
H 12 Hour hour system. One-digit hours do not have leading zeros.
HH 12-hour hour. One-digit hours have leading zeros.
H 24 hour hour system. One-digit hours do not have leading zeros.
HH 24-hour hour. One-digit hours have leading zeros.
M minutes. A single-digit number of minutes does not have a leading zero.
MM minutes. A single-digit number of minutes has a leading zero.
s seconds. The number of seconds in a single digit does not have a leading zero.
SS seconds. The number of seconds of one digit has a leading zero.
The fractional precision of the F-second is one digit. The remaining digits are truncated.
The fractional precision of the FF seconds is two bits. The remaining digits are truncated.
String.Format("{0:y yy yyy yyyy}", dt); // "8 08 008 2008" year
String.Format("{0:M MM MMM MMMM}", dt); // "3 03 Mar March" month
String.Format("{0:d dd ddd dddd}", dt); // "9 09 Sun Sunday" day
String.Format("{0:h hh H HH}", dt); // "4 04 16 16" hour 12/24
String.Format("{0:m mm}", dt); // "5 05" minute
String.Format("{0:s ss}", dt); // "7 07" second
String.Format("{0:f ff fff ffff}", dt); // "1 12 123 1230" sec.fraction
String.Format("{0:F FF FFF FFFF}", dt); // "1 12 123 123" without zeroes
String.Format("{0:t tt}", dt); // "P PM" A.M. or P.M.
String.Format("{0:z zz zzz}", dt); // "-6 -06 -06:00" time zone
From for notes (Wiz)
C # often forgets knowledge