문제

GetMonthName's virtual ToString method that inside DateTimeFormatInfo class is not working properly.I 'm adding culture code to CultureInfo but it is returning invariant value.

DateTimeFormatInfo d = new DateTimeFormatInfo();
d.GetMonthName(1).ToString(new CultureInfo("tr-TR")); // returns January
도움이 되었습니까?

해결책

GetMonthName returns a string. There is no translation that happens when you call toString on a string even if you provide a CultureInfo. What you want to do is something like this:

var trTr = new CultureInfo("tr-TR");
trTr.DateTimeFormat.GetMonthName(1);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top