October 16, 2007

Changing system culture programatically in C# .NET

This is useful when handling dates in US or other format in C# .NET:

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US", False)
Row.date = MonthName(Row.datahorainicio.Month(), True) & " " & Row.datahorainicio.Day() & " " & Row.datahorainicio.Year()

'reset the culture to the system's default
Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT", False)

No comments: