Skip to main content

Currency formatting in C#


string.Format("{0:c}", 102);

Using the above code will return a result like $102.00. Since by default $ sign comes and if you want to change the symbol to other like pound or sterling change the culture info details as the below code sample.

string.Format(new CultureInfo("en-US"), "{0:c}", 102);

// This code again gives $ symbol since I have used “en-US” ;). Please check the sample language codes below to use the symbol you require the complete list of language code is available in this url “http://msdn.microsoft.com/en-us/library/ms533052(v=vs.85).aspx”.

en-us
English (United States)
en-gb
English (United Kingdom)
en-au
English (Australia)
en-ca
English (Canada)
en-nz
English (New Zealand)
en-ie
English (Ireland)
en-za
English (South Africa)
en-jm
English (Jamaica)
en
English (Caribbean)
en-bz
English (Belize)
en-tt
English (Trinidad)
et
Estonian
fo
Faeroese
fa
Farsi
fi
Finnish
fr
French (Standard)
fr-be
French (Belgium)
fr-ca
French (Canada)
fr-ch
French (Switzerland)
fr-lu
French (Luxembourg)
gd
Gaelic (Scotland)
ga
Irish
de
German (Standard)
de-ch
German (Switzerland)
de-at
German (Austria)
de-lu
German (Luxembourg)
de-li
German (Liechtenstein)
el
Greek

For other formatting check this link : http://msdn.microsoft.com/en-us/library/s8s7t687(v=vs.71).aspx

Comments

Popular posts from this blog

Creating multi module project with maven

Creating my first multi module project with maven I got a superb step by step article for maven project creation in eclipse while googling. This article is good for beginners like me :) , no need do too many things, just follow the steps at the end you will see “Hello World” in the browser. Check the below link for the wonderful article. http://skillshared.blogspot.in/2012/11/how-to-create-multi-module-project-with.html Thanks Semika Loku Kaluge

Unable to convert MySQL date/time value to System.DateTime - Solved

Few days back I got an exception like 'Unable to convert Mysql date/time value to system.datetime' but this happened only after deploying and locally everything was working fine. After googling for sometimes found the reason that, it was due to the formatting difference between Mysql and C# also empty date value is causing some issue. Later found the below solution to fix'em. Add an extra property(Convert Zero Datetime = true) to connectino string. e.g server=localhost;User Id=root;password=pwd;database=test; Convert Zero Datetime=true Solution obtained from StackOverflow :)

Converting String to a Executable line in JAVA

I've been searching for converting a string into a executable line so that I could process it... after searching for sometime, as usual I got a solution in the name of BeanShell scripting awesome one... This is another scripting language built with Java, which is powerful and was able to solve my need... This is the link for it : http://www.beanshell.org/manual/bshmanual.html#Download_and_Run_BeanShell Hope this helps you as well... If anyone requires any help on this, a basic one ;) ... sure post a comment, will help if I could...