Calendar.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 virtual int TwoDigitYearMax { get; set; }
member this.TwoDigitYearMax : int with get, set
Public Overridable Property TwoDigitYearMax As Integer

屬性值

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

例外狀況

目前的 Calendar 物件是唯讀的。The current Calendar object 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. Calendar 類別不會自動偵測系統設定中的變更。The Calendar class does not detect changes in the system settings automatically. 如果 [地區及語言] 選項不支援行事曆,此屬性的初始值就是 Calendar 類別所定義的預設值。If the calendar is not supported in the regional and language options, the initial value of this property is the default value defined by the Calendar class.

您的應用程式應該將此值設定為99,以表示要以逐字的形式來執行2位數的年份。Your 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.

適用於

另請參閱