简体   繁体   中英

Specify culture for application c#

my computer is set to america datetime culture dd-mm-yyyy but in my application I want to use yy-mm-dd so I want to use swedish culture no matter what the computer culture is set to. using this line dosen't always work Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE"); It's a asp.net web application.

Setting the culture for the thread only works for code executed after that line. Also a request can be handled by different threads in different stages, so you would need to repeat that line after each point where a thread switch is possible.

To set the culture globally you can specify the culture in the system.web section in web.config :

<globalization culture="sv-SE" uiCulture="sv-SE" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM