There is a live .NET Web Service which offers
all the curreny conversion eg. USD to INR etc.
This WS is available via live URL
http://www.webservicex.net/CurrencyConvertor.asmx
This WS has a class CurrecnyConvertor which exposes one Function named
ConversionRate and an enum named Currency which exposed the list of all the
currencies like USD, INR, AED etc.
As you know Currency conversion will depend on two parameters ConvertFrom and
ConvertTo and so the same is expected to be passsed while invoking
ConversionRate function.
Here is a detailed list of steps:
- Add a Web Reference to http://www.webservicex.net/CurrencyConvertor.asmx
- Rename the Reference name to something more friendly like CurrencyConversionWS
- In your project create an instance of the added Web service reference
- On the created object invoke the ConversionRate function.
- As mentioned above there is an enum which lists all the currencies and so access it directly from the object created.
- Save the result into a double variable and multiply with your passed amount.
- Multiply the amount you want to convert to the received conversion rate.
Here is the code you will require to have
it all working:
CurrencyConversionWS.CurrencyConvertor
objWS =
new
CurrencyConversionWS.CurrencyConvertor();
double
usdToinr = objWS.ConversionRate(CurrencyConversionWS.Currency.USD,
CurrencyConversionWS.Currency.INR);
double
totalAmount = usdToinr *
Double.Parse(textBox1.Text);
MessageBox.Show(totalAmount.ToString(),"Total
Indian Rupees");
This is how it will look like:


Naveed ZamanPosted Jul 24, 2015, 11:46 PM
Very Nice Please confirm MessageBox.Show ? How can we use this in ASP. Net. I think this code is for desktop Application Please Confirm
Nemi ChandPosted Jun 4, 2015, 5:58 AM
Nice. very Helpful
Nitesh KejriwalPosted Sep 7, 2014, 2:30 AM
Great one Vidya!!!
Virendra GourPosted Sep 6, 2014, 1:08 PM
nice..vidya sir.
Former memberPosted Sep 6, 2014, 11:44 AM
Hey Sudheer, it's working fine for me. Check the correct code already mentioned on the link. It's case sensitive (e.g INR to USD will give the correct result but inr to usd will result in error page)
sudheer MPosted Jun 3, 2014, 8:04 AM
Hi,am getting request failed error. What can i do?
Vidya Vrat AgarwalPosted Dec 26, 2012, 1:24 PM
Hi Mahesh, Thanks. Yes its Free .asmx Web Service :) with live rates.
Mahesh ChandPosted Dec 26, 2012, 1:02 PM
Nice. Is the service free?