GregorianCalendar.TwoDigitYearMax 屬性

定義

取得或設定以二位數年份表示時,該 100 年範圍的最後一年。Gets or sets the last year of a 100-year range that can be represented by a 2-digit year.

public:
 virtual property int TwoDigitYearMax { int get(); void set(int value); };
public override int TwoDigitYearMax { get; set; }
member this.TwoDigitYearMax : int with get, set
Public Overrides Property TwoDigitYearMax As Integer

屬性值

以二位數年份表示時,該 100 年範圍的最後一年。The last year of a 100-year range that can be represented by a 2-digit year.

例外狀況

在設定作業中指定的值小於 99。The value specified in a set operation is less than 99.

-或--or- 在設定作業中指定的值大於 MaxSupportedDateTime.YearThe value specified in a set operation is greater than MaxSupportedDateTime.Year.

在設定作業中,目前執行個體是唯讀的。In a set operation, the current instance is read-only.

備註

這個屬性可讓2位數的年份正確轉譯成4位數的年份。This property allows a 2-digit year to be properly translated to a 4-digit year. 例如,如果此屬性設定為2029,則100年的範圍是從1930到2029。For example, if this property is set to 2029, the 100-year range is from 1930 to 2029. 因此,2位數值30會被視為1930,而2位數的值29則會轉譯為2029。Therefore, a 2-digit value of 30 is interpreted as 1930, while a 2-digit value of 29 is interpreted as 2029.

這個屬性的初始值衍生自 [控制台] 的 [地區及語言選項] 部分中的設定。The initial value of this property is derived from the settings in the regional and language options portion of Control Panel. 不過,該資訊可能會在 AppDomain的生命週期中變更。However, that information can change during the life of the AppDomain. GregorianCalendar 類別不會自動偵測系統設定中的變更。The GregorianCalendar class does not detect changes in the system settings automatically.

應用程式應將此值設定為99,表示要以逐字的形式採用2位數的年份。The application should set this value to 99 to indicate that 2-digit years are to be taken literally. 例如,如果此屬性設定為99,則100年的範圍是從0(不是大部分行事曆的有效值)到99。For example, if this property is set to 99, the 100-year range is from 0 (not a valid value for most calendars) to 99. 因此,2位數值30會被視為30。Therefore, a 2-digit value of 30 is interpreted as 30.

適用於

另請參閱