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: