simple currency converter?
I'm trying to write a web service function in C# to be able to convert currencies between gbp,eur,usd
so if i called CurrencyConversion(gbp, usd, 10.00) it should convert 10 pounds into us dollars and return that, can someone give me an example how this could be done?
Code:
public class TestService : WebService
{
[WebMethod(Description = "GBP<->EUR<->USD currency conversion", EnableSession = false)]
public int CurrencyConversion(string currency1, string currency2, decimal amount)
{
}
}
Re: simple currency converter?
You'd need to parse the two currencies to determine which exchange rate to use, then simply multiply the amount by that value. Where you get your exchange rates from is up to you. Also, shouldn't that method return a decimal, not an int?
Re: simple currency converter?
Yep, thanks, changed it to decimal.
If i now created an asp.net website within the same project, how would i call this service to test my currency converter service?