cultureinfo

Why isn't there a culture enum?

喜欢而已 提交于 2019-12-04 03:21:06
Greetings, I was wondering why there isn't a pre-set enum for cultures in C#? Since the cultures never change and are always like "nl-NL, en-GB, en-US".. why not make a enum for it to make things just a little bit easy'r ? [edit] As stated cultures do change.. but not all. Why not make a enum / class type which holds all the cultures and gives the possibility to add / change them ? "Since the cultures never change" Don't they? This article (Microsoft .NET Framework 4: What is New in Globalization) disagrees. In the past 5 years alone, a lot has changed in the region of Serbia for example,

.Net CultureInfo Month Names returning an extra empty string

回眸只為那壹抹淺笑 提交于 2019-12-04 00:09:52
I have the following code to get a list of Month names: var monthNames = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames; For some reason, this keeps returning an additional empty string value along with the Month names: I am using Xamarin Studio. Anyone else encounter this before? Some calendars like TaiwanLunisolarCalendar or KoreanLunisolarCalendar have 13 months. In a 12-month calendar, the 13th element of the array is an empty string. DateTimeFormatInfo.MonthNames A one-dimensional array of type String containing the culture-specific full names of the months. In

CultureInfo issue with Modelbinding double in asp.net-mvc(2)

笑着哭i 提交于 2019-12-03 14:11:11
In my Jquery script I post two doubles using the browser's CultureInfo (en-UK) that uses the . as a fraction separator. My MVC app is running on a server with locale nl-BE using the , as a fraction separator. [AcceptVerbs(HttpVerbs.Post)] public JsonResult GetGridCell(double longitude, double latitude) { var cell = new GridCellViewModel { X = (int)Math.Round(longitude, 0), Y = (int)Math.Round(latitude, 0) }; return Json(cell); } The modelbinding fails because of the parsing issue. I think it would be best to have my javascript set to en-UK and the same for the modelbinding in my MVC app. But I

How to get timezone from properties in CultureInfo

心不动则不痛 提交于 2019-12-03 06:58:54
I have a string, which contains a timestamp ( yyyy-mm-dd hh:mm:ss ) . I can create a CultureInfo object based on other information I get. Therefore I know which country the timestamp is in. The timestamp is not in UTC/GMT. Say the timestamp is from Indonesia ( new CultureInfo("id-ID") ) , meaning the string was created by code below or similar. DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); That means the string contains the local time in Indonesia. I know my timezone, but I don't know how to convert the Indonesian time to UTC/GMT, so I can use the UTC/GMT object in TimeZoneInfo . My own

How to Convert Persian Digits in variable to English Digits Using Culture?

心已入冬 提交于 2019-12-03 06:42:02
问题 I want to change persian numbers which are saved in variable like this : string Value="۱۰۳۶۷۵۱"; to string Value="1036751"; How can I use easy way like culture info to do this please? my sample code is: List<string> NERKHCOlist = new List<string>(); NERKHCOlist = ScrappingFunction(NERKHCO, NERKHCOlist); int NERKHCO_Price = int.Parse(NERKHCOlist[0]);//NERKHCOlist[0]=۱۰۳۶۷۵۱ <= So it can not Parsed it to int And This is in my function which retun a list with persian digits inside list items

Passing a DateTime to controller via URL causing error in ASP .NET MVC 3 (culture)

守給你的承諾、 提交于 2019-12-02 22:32:31
My application is setted with pt-BR culture (Date is dd-mm-yyyy) in web.config: <globalization enableClientBasedCulture="false" requestEncoding="utf-8" responseEncoding="utf-8" fileEncoding="iso-8859-15" responseHeaderEncoding="utf-8" resourceProviderFactoryType="string" enableBestFitResponseEncoding="true" culture="pt-BR" uiCulture="pt-BR" /> All DateTime created on my system is in right format, but I created a controller method like that: public ActionResult Test(DateTime date) { } Calling that method direct in the browser is passing null when the date is with portuguese-br format, like that

How to Convert Persian Digits in variable to English Digits Using Culture?

谁说胖子不能爱 提交于 2019-12-02 20:19:25
I want to change persian numbers which are saved in variable like this : string Value="۱۰۳۶۷۵۱"; to string Value="1036751"; How can I use easy way like culture info to do this please? my sample code is: List<string> NERKHCOlist = new List<string>(); NERKHCOlist = ScrappingFunction(NERKHCO, NERKHCOlist); int NERKHCO_Price = int.Parse(NERKHCOlist[0]);//NERKHCOlist[0]=۱۰۳۶۷۵۱ <= So it can not Parsed it to int And This is in my function which retun a list with persian digits inside list items protected List<string> ScrappingFunction(string SiteAddress, List<string> NodesList) { string Price =

Modify application wide, the display of DateTime

怎甘沉沦 提交于 2019-12-02 08:53:20
问题 For an application we develop, we use the "G" format everywhere in our application. We want to change a little bit this format: We need to display the first digit after the second. Ex: 29.07.2014 08:54:36.1 We would like to be able to change this in the CurrentCulture . It's the only thing we want to change in the current culture, so if before, we were having the following format: 2014/07/29 08:54:36 AM We then want to have 2014/07/29 08:54:36.1 AM If before I was having 29.07.2014 08:54:36

How to format double without fractional part

筅森魡賤 提交于 2019-12-02 07:22:11
The value am sending is 100233 double value = 100233; string a = (value.ToString("N", CultureInfo.InvariantCulture)); output 100,233.00 but i want 100,233 i don't want the trailing zeros . Is there any specific way to get it ? you are close double value = 100233; string a = (value.ToString("N0", CultureInfo.InvariantCulture)); 来源: https://stackoverflow.com/questions/17058182/how-to-format-double-without-fractional-part