Background
In one of my projects there is one module that requires a currency converter application. I am applying various techniques to convert the currency, such as storing the country name and related currency values in a database and retrieve them according to the related country but that is a very lengthy and complicated process.
Then after trying many options I decided to use a third party API to complete my requirement; I chose the Google API. So my intent is to write this article to help others that might me need to do the same type of task.
So let us start with the walkthrough.
Create the project as in:
- "Start" - "All Programs" - "Microsoft Visual Studio 2010".
- "File" - "New Project" - "C#" - "Empty Project" (to avoid adding a master page).
- Give the Project name (such as LiveCurrencyconverter) or another as you wish and specify the location.
- Then right-click on Solution Explorer - "Add New Item" - "Default.aspx" page.
- Then right-click on Solution Explorer - "Add New Item" - "WebService.asmx" page.
- To see the "Default.aspx" source code please download the sample zip file.
Use the following code in WebService.asmx.cs of the WebService.asmx page:

In the preceding web services I have used one string named URL; on it I have saved a path of the Google API. Now add the service reference of the WebService.asmx web service to the Default.aspx page by right-clicking on the Solution Explorer, now run the application which looks such as in the following:

The above is the sample screen of an application, now provide the Input i9n above fields and click on "Convert" Button; the output will be as follows:

In the preceding Screen we can clearly seen that, I have converted 1 USD into Indian Rupees and the output is exactly the current market price, which is 54.58Rs.
Advantages
- Convert any country's currency using the current live market value.
- You have no need of a database to store the data.
- The free of cost API is provided by Google; there is not even a hidden cost.
Note
- For more code please download the sample zip file.
- Before using this article please read about the basics of Web Services, if you are unfamiliar with it.
Summary
I hope this article is useful for all readers, if you have any suggestion then please contact me, because of your suggestion others can get help from this article by improving it.

Aman KumarPosted Sep 30, 2020, 1:18 PM
Where is WebService.asmx and WebService.asmx.cs code in the file. what a joke.
Vishal mahajanPosted May 14, 2019, 12:34 PM
In download link Cs file is empty Please dont make a Joke
Annam SumanthPosted Oct 19, 2018, 12:50 PM
Why this zip file is not downloading?
hirachand mudhalePosted May 17, 2016, 3:43 AM
could you give me available free api ...
Vithal WadjePosted Feb 28, 2016, 11:38 PM
Thanks .. please check latest API
Salman KavishPosted Feb 27, 2016, 1:37 PM
Nice article.
Salman KavishPosted Feb 27, 2016, 1:37 PM
public string CurrencyConversion(decimal amount, string fromCurrency, string toCurrency) { string Output = ""; const string fromCurrency1 = "USD"; const string toCurrency1 = "INR"; const double amount1 = 2000; // For other currency symbols see http://finance.yahoo.com/currency-converter/ // Construct URL to query the Yahoo! Finance API const string urlPattern = "http://finance.yahoo.com/d/quotes.csv?s={0}{1}=X&f=l1"; string url = string.Format(urlPattern, fromCurrency1, toCurrency1); // Get response as string string response = new WebClient().DownloadString(url); // Convert string to number double exchangeRate = double.Parse(response, System.Globalization.CultureInfo.InvariantCulture); // Output the result Output=(amount1*exchangeRate).ToString(); return Output; // http://salmankavish.blogspot.in/2016/02/currency-converter-using-c.html }
Salman KavishPosted Feb 27, 2016, 1:37 PM
i have use yahoo finance api. one can take ref from following code.
Mark OngPosted Aug 10, 2015, 4:28 AM
I have encounter errors regarding "the type or namespace name could not be found". Any Solutions for that ?
ajay kumarPosted Aug 10, 2015, 1:26 AM
This article seems outdated now, http://www.google.com/ig/calculator api is no longer up and running
Rajagopalan R VPosted Apr 22, 2015, 8:45 AM
Hi Mr. Vithal Wadje the following link in this Application Jquery/JScript.js Code Page (Link Consists Page) http://www.geoplugin.net/currency_converter.gp?jsoncallback=? is throwing " ERR01 "
Vithal WadjePosted Dec 29, 2014, 9:57 PM
need to be install valid https certificate
hemant sharmaPosted Dec 26, 2014, 9:00 AM
Its not working on https
Vithal WadjePosted Jun 4, 2014, 1:32 PM
download above zip file
Sumit TesterPosted Jun 3, 2014, 3:58 PM
Please send me the updated code. My email id is: [email protected]
sameer albalushiPosted May 12, 2014, 3:04 PM
please send me the updated code my id is [email protected]
Sehrish AliPosted Mar 28, 2014, 9:55 AM
please send me updated code too my id is [email protected]
Vithal WadjePosted Feb 25, 2014, 12:28 PM
shaukeen khan sir send mi your sample code
shaukeen khanPosted Feb 25, 2014, 6:07 AM
dear code run but i am not getting any result ? please help
ketan italiyaPosted Nov 22, 2013, 3:17 AM
Sir,Everything is work but option in dropdown for select indian ruppes into dollar etc. is not shown is that google api related problems
ketan italiyaPosted Nov 22, 2013, 2:16 AM
thankss.sir
Vithal WadjePosted Nov 21, 2013, 1:19 PM
download updated
pappu singhPosted Nov 21, 2013, 6:31 AM
LiveCurrencyConverter.zip not working
Vithal WadjePosted Nov 16, 2013, 1:24 PM
thanks sir check your email,same i will be update here
althaf22Posted Nov 16, 2013, 8:44 AM
Hi vithal.Jee , Code is giving run time error in Regular expression line, C#, plz send me the updated one plz. to [email protected]
Vithal WadjePosted Nov 8, 2013, 1:19 PM
thanks Geetha Mdm, message me your email Id on C# corner, i will send you latest solution
Geetha LaksmiPosted Nov 7, 2013, 10:44 PM
hi,the code is working but it found an error at the regex part....can you help me with this
Hitesh GuptaPosted Oct 18, 2013, 8:29 AM
When I am using regularly, It stop working due to captcha..
dinesh kumarPosted Oct 12, 2013, 9:22 PM
helpfull for me ;;but i want to be get this updated currency in database plz give me code for this
Vithal WadjePosted Mar 26, 2013, 6:02 AM
chill sir,make some changes according to your VS and then run
chill applePosted Feb 3, 2013, 3:37 AM
it is showing assembly error
Vithal WadjePosted Jan 11, 2013, 4:08 AM
thanx sir
duc nguyeneditedPosted Jan 11, 2013, 2:54 AMEdited Feb 3, 2013, 11:05 PM
Thank you! this is helpful for me