currentculture

Best way to parse float?

What is the best way to parse a float in CSharp? I know about TryParse, but what I'm particularly wondering about is dots, commas etc. I'm having problems with my website. On my dev server, the ',' is for decimals, the '.' for separator. On the prod server though, it is the other way round. How can I best capture this? ...

C# doubles show comma instead of period

Hi I almost have the same problem as the guy in this thread: http://stackoverflow.com/questions/359298/convert-float-that-has-period-instead-of-comma So that my double x = 234.4; string y = x.ToString(); I get y == "234,4"; Even worse ... Double.Parse("234.4") throws an exception. I have written alot of code before I was asked to...

Override CurrentCulture for Winforms control

Hi, Does one of you know if its possible to override the CurrentCulture and the CurrentUICulture for a specific control in Winforms? So that this one specific controls uses a different culture? tia Martin ...

Does changing the culture of a threadpool thread affect it when it gets returned back to the pool?

If I set the CurrentCulture of a thread pool thread, what happens when the thread finishes execution and gets returned back to the thread pool? Does it get its CurrentCulture reset back to the default (whatever that may mean), or will it retain the culture I have set on it? I'm hoping that the framework resets the thread to a default ...

Set the Culture for an asp.net RangeValidator

An asp:RangeValidator takes it's culture info from the page/ thread and all advice online around getting the right culture seems to be to set the CultureInfo on the thread. Rick Strahl's west wind blog is typical advice However, due to problems running the server code in this way, we are stripping out the code we were using previously ...

How do I feed the language culture thread into the helper class

Hi everyone, With asp.net MVC 2, I have been trying to get Matt Hawley's Localization helper to work in my web application, but I am getting stuck feeding a null into the Language string variable. I can't figure out why I am doing this. namespace MvcLocalization { public abstract class LocalizedControllerBase : Controller { public ...

ASP.NET Setting Culture with InitializeCulture

I have a website with three domains .com, .de and .it Each domain needs to default to the local language/culture of the country. I have created a base page and added an InitializeCulture Protected Overrides Sub InitializeCulture() Dim url As System.Uri = Request.Url Dim hostname As String = url.Host.ToString() Dim Selec...

int.Parse of "8" fails. int.Parse always requires CultureInfo.InvariantCulture?

We develop an established software which works fine on all known computers except one. The problem is to parse strings that begin with "8". It seems like "8" in the beginning of a string is a reserved character. Parsing: int.Parse("8") -> Exception message: Input string was not in a correct format. int.Parse("80") -> 0 int.Parse("88") ...

How to honor/inherit user's language settings in WinForm app

I have worked with globalization settings in the past but not within the .NET environment, which is the topic of this question. What I am seeing is most certainly due to knowledge I have yet to learn so I would appreciate illumination on the following. Setup: My default language setting is English (en-us specifically). I added a secon...

Why doesn't the Timezone change when I set the CurrentCulture?

From what I have researched it is not possible to change the Timezone of a thread. So my question is why can't you? I would have thought switching your application's culture to a specific country would also switch this, seems like expected behaviour IMO. Edit After revising I can see the reason why it probably shouldn't be mapped 1:1 ...

Can CultureInfo.CurrentCulture differ per application pool?

I'm having trouble with CultureInfo in our ASP.NET web application. Our web application returns a different culture, depending on which application pool it is in. In application pool A, it is en-US, but in application pool B, it's nl-BE. I'd like it to be nl-BE, but can't find where to change this (IIS6 by the way). I'm not even sure ...

Windows service and default code page/culture setting?

Hi, I'm writing a service that will read a file from a directory, read the contents of the file and process the content. I am having issues with Swedish characters that are read from the file as they are beeing translated into "garbage chars" by the service when they are read. Does anyone know what default code page/culture setting is...

Thread.CurrentCulture refers to client or server

Hi, simple question: Where does Thread.CurrentCulture gets it's data from? Client (browser) or server. And another question, is this the right way to find out the culture of the user? Thanks ...

CultureInfo.CurrentCulture is giving me the wrong culture

I'm trying to get my clients' country, so I use CultureInfo.CurrentCulture. Problem is that when my Canadian customers use my website, they're showing up as American. It looks like CultureInfo.CurrentCulture is returning my server's country instead of their country. So how do I get my clients' country? ...

When should I specify CurrentCulture or InvariantCulture and when should I leave it unspecified?

What is the best practice for specifying CurrentCulture or InvariantCulture and not specifying the culture at all? From what I have read, if you're doing serialization, for instance, you need InvariantCulture as a means of specifying a canonical representation of a data value. That's a relatively small percentage of culture-based stri...

C# ws 2003 asp.net currentculture different to currentuiculture on one machine but not other

Hi all, I have two webservers, both ws 2003 machines, running behind a load balancer. machine 1 is working correct but machine 2 is incorrect. They are both running the same code base and use the same configuration. The issue is that dates are not working correctly on machine 2, we realized that it was due to the culture. machine 1:...

How to set current CultureUI via XAML binding

I have a TextBlock bound to a string. I want the string to be displayed in current UI culture of the application. I want to do this in XAML. The text block is simple like below. <TextBlock Text="{Binding Path=Text}"/> ...

Get current computer datetimeformat

Hi I am new to web programming and I have an mvc app which runs on azure. There is a functionality where users can export grid data to csv and one of the fields is a datetime field. When the user clicks on export I take whatever is in the grid, format it to csv and then return a FileContentResult. The problem I have is that since the con...