|
Dieser Artikel wurde maschinell übersetzt. Bewegen Sie den Mauszeiger über die Sätze im Artikel, um den Originaltext anzuzeigen. Weitere Informationen
|
Übersetzung
Original
|
TaiwanCalendar.GetWeekOfYear-Methode
Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
[ComVisibleAttribute(false)] public override int GetWeekOfYear( DateTime time, CalendarWeekRule rule, DayOfWeek firstDayOfWeek )
Parameter
- time
- Typ: System.DateTime
Die zu lesende DateTime.
- rule
- Typ: System.Globalization.CalendarWeekRule
Einer der CalendarWeekRule-Werte, die eine Kalenderwoche definieren.
- firstDayOfWeek
- Typ: System.DayOfWeek
Einer der DayOfWeek-Werte, die den ersten Tag der Woche darstellen.
Rückgabewert
Typ: System.Int32| Ausnahme | Bedingung |
|---|---|
| ArgumentOutOfRangeException |
using System; using System.Globalization; public class SamplesCalendar { public static void Main() { // Gets the Calendar instance associated with a CultureInfo. CultureInfo myCI = new CultureInfo("en-US"); Calendar myCal = myCI.Calendar; // Gets the DTFI properties required by GetWeekOfYear. CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule; DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek; // Displays the number of the current week relative to the beginning of the year. Console.WriteLine( "The CalendarWeekRule used for the en-US culture is {0}.", myCWR ); Console.WriteLine( "The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW ); Console.WriteLine( "Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear( DateTime.Now, myCWR, myFirstDOW )); // Displays the total number of weeks in the current year. DateTime LastDay = new System.DateTime( DateTime.Now.Year, 12, 31 ); Console.WriteLine( "There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear( LastDay, myCWR, myFirstDOW ), LastDay.Year ); } } /* This code produces the following output. Results vary depending on the system date. The CalendarWeekRule used for the en-US culture is FirstDay. The FirstDayOfWeek used for the en-US culture is Sunday. Therefore, the current week is Week 1 of the current year. There are 53 weeks in the current year (2001). */
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core-Rolle wird nicht unterstützt), Windows Server 2008 R2 (Server Core-Rolle wird mit SP1 oder höher unterstützt; Itanium wird nicht unterstützt)
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.