How to read "List Separator" settings from Regional configuration of control panel?
Asked Answered
C

1

47

I'm making multi culture plugin for MS Word,Excel where I need to identify setting value provided in Regional Settings under "List Separator" Option, how can I read using C# ?

This List separator is later on being used to construct Excel formulas, word mail merge header, etc.

Capitol answered 26/7, 2011 at 18:11 Comment(0)
O
62

Try using System.Globalization.CultureInfo.CurrentCulture.TextInfo.ListSeparator or System.Globalization.CultureInfo.GetCultureInfo("en-US").TextInfo.ListSeparator if you look for a specific culture's information.

Odiliaodille answered 26/7, 2011 at 20:48 Comment(3)
Just as a side note if you plan to use CurrentCulture: make sure there is no code that change the Thread Culture. Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("fr-CA"); msdn.microsoft.com/en-us/library/…Antistrophe
If someone changes the current culture of the thread it's usually to make the new settings effect things like these (exports, format). That's why there are two current cultures: one for the thread and one for the UI (CurrentUICulture). Just make sure you are using the one you need, and don't worry if someone changes it.Platas
To clarify @AlexMazzariol comment, which seems to imply that threads only have one culture: Threads have both CurrentCulture and CurrentUICulture. CurrentCulture determines formatting rules for dates, numbers, etc., while CurrentUICulture determines the language used.Selfsacrifice

© 2022 - 2024 — McMap. All rights reserved.