c# - When parsing datetime into month day with English culture, it is still parsed in Turkish language -
here code. still incorrect results
string srregisterdate = "25.07.2009 00:00:00" cultureinfo culture = new cultureinfo("en-us"); srregisterdate = string.format("{0:dddd, mmmm d, yyyy}", convert.todatetime(srregisterdate), culture); the result cumartesi, temmuz 25, 2009
instead should saturday, july 25, 2009
how can fix error?
c#.net v4.5.2
the issue because of ignored culture value in string.format , not converting string datetime.
you need:
srregisterdate = string.format(culture, "{0:dddd, mmmm d, yyyy}", convert.todatetime(srregisterdate)); your current call string.format utalizes overload string.format method (string, object[]) , culture passed in parameter treated simple object parameter passed place holder. since there no place holder, don't see getting ignored.
if want have culture utilized in string.format have use overload : format(iformatprovider, string, object) or string.format method (iformatprovider, string, object[])
Comments
Post a Comment