Autor Beitrag
paul.-b
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Di 27.04.10 16:52 
Hallo,

Wenn ich dt.Month ausgebe dann kommt 4 (für April)
gebe ich mir das ganze aber so aus:

Zitat:
System.Globalization.CultureInfo.CreateSpecificCulture("de").DateTimeFormat.MonthNames.GetValue(dt.Month).ToString();


dann kommt "Mai".
Kann mir jemand erklären warum das so ist?

lg
Paul
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 27.04.10 17:07 
MonthNames ist ein Array und damit null-basiert.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Di 27.04.10 17:10 
Jep, deshalb der Fehler.

Warum machst du es aber generell so umständlich?

Ein DateTime Objekt hat ja die Methode ToString(). Damit kannst du dir die Zeit in einer beliebigen Formatierung ausgeben.. unter Anderem auch die die gerade eingestellt ist.
paul.-b Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Di 27.04.10 20:48 
Das ist es, ich will immer deutsch haben, egal was eingestellt ist!
Gibt es eine gute Lösung dafür?
danielf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1012
Erhaltene Danke: 24

Windows XP
C#, Visual Studio
BeitragVerfasst: Di 27.04.10 21:09 
Immer deutsch wäre dann: CultureInfo.GetCultureInfo("de-de")
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 27.04.10 21:11 
Oder kürzer new CultureInfo("de-DE"); :-)

Das kann man dann als Parameter der ToString-Methode übergeben.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
paul.-b Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Fr 30.04.10 14:46 
Danke! Problem gelöst, bitte hier schließen!
Paul