Results 1 to 3 of 3

Thread: simple currency converter?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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)
        {
    
        }
    
    }

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width