Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String.Format and culture

Tags:

c#

.net

culture

When formatting a string as opposed to a DateTime, does the culture ever come into play? Are there any examples of strings that would be formatted differently with two different cultures?

like image 957
Joe Cartano Avatar asked Jul 16 '26 06:07

Joe Cartano


2 Answers

I don't believe so in the current Framework. But if Microsoft ever implements this suggestion on the Connect feedback site, it includes a suggestion to have a format specifier to force upper case:

String.Format("{0:U}", "SomeString") => "SOMESTRING"

Such formatting would be culture-specific.

like image 50
Joe Avatar answered Jul 18 '26 19:07

Joe


If you are displaying a string that is stored as a resource it will make a difference if you have separate strings for different cultures (you'd use CultureInfo.CurrentUICulture). For example error messages accessed via a ResourceManager.

like image 39
Jason Down Avatar answered Jul 18 '26 19:07

Jason Down



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!