![]() In your case, you apparently mean "US dollar"Īn alternative is to provide a class with named constants for designating various currencies. ![]() "dollar" is ambiguous, as many currencies are called dollar in some form."ron" is the currency code for the Romanian leu."euro" is the full name of the currency.This is made worse as your choice of strings is inconsistent: This makes it hard to maintain, and leaves the caller guessing how to call your functions. You check you function parameters against hard-coded and undocumented strings. Just request the one exchange rate you need after resolving which currencies you are dealing with. You get 6 exchange rates from the server each time you call your method, when you only need one. Prefer the decimal type in these applications. This is fine for a lot of applications, but it is an issue for currency, where rounding errors can cause money to disappear or be created from thin air. The double type can't accurately represent base-10 decimal numbers. Return currencyValue * Convert.ToDouble(ronToEur) If (firstCurrency = "ron" & secondCurrency = "euro") Return currencyValue * Convert.ToDouble(ronToUsd) If (firstCurrency = "ron" & secondCurrency = "dollar") Return currencyValue * Convert.ToDouble(eurToRon) If (firstCurrency = "euro" & secondCurrency = "ron") Return currencyValue * Convert.ToDouble(eurToUsd) If (firstCurrency = "euro" & secondCurrency = "dollar") Return currencyValue * Convert.ToDouble(usdToRon) If (firstCurrency = "dollar" & secondCurrency = "ron") Return currencyValue * Convert.ToDouble(usdToEur) If (firstCurrency = "dollar" & secondCurrency = "euro") Var ronToEur = client.DownloadString("") Ĭomplete Method: static double PerformConversion(string firstCurrency, string secondCurrency, double currencyValue) Var ronToUsd = client.DownloadString("") Var eurToRon = client.DownloadString("") Var eurToUsd = client.DownloadString("") Var usdToRon = client.DownloadString("") Var usdToEur = client.DownloadString("") I found this method working: var client = new WebClient() But, being new I am always skeptical if it's done the proper way. I want to use real time exchange rates through an api when sending the result. Url: " WebService.I am in my first week of programming and I created a currency converter. I just created this CSS for a better look and feel to the UI. You can get the country list and codes from the attached file. Once you click on the Convert button, it will call a jQuery Ajax method which calls a webmethod internally. Here, Textbox is used to capture the amount which needs to be converted to the desired currency from the current currency and two dropdowns are prefilled with the Currency Code and Country Names. Two dropdowns, one text box and one button, the result is just displayed in a table cell. The Currency Converter solution will look like the below screen:Īs you can see from the screenshot belo, the UI contains very few controls. In this project, the main components are ASPX, CSS, jQuery and Web service. Click here to see Yahoo’s Online Currency Converter or else see the below given screenshot. csv file with the currency conversion rate. Yahoo’s real-time currency converter API will give you a. If you haven’t checked this service yet, then click here or else see the below given screenshot. Why it's hidden, because this API doesn't come with an official document. Google is using their own hidden API for showing the real-time currency rate in their search engine. Let me try to explain the steps for you… Background Your votes, suggestions and feedback are highly appreciated to improve the quality of this and upcoming articles, please don't forget. For your reference, I have attached the source code with this article. Click here to view Available APIs from Yahoo.įor this article, I have created a web application from scratch that will pull data from Google/Yahoo and will display in user interface using jQuery Ajax and Web service.Click here to view Available APIs from Google.Here, I’m going to show a Real-time Currency Converter using Google’s/Yahoo’s API. Google, Yahoo provides many APIs that can be used in our applications. Download Currenc圜onverter_VS2008_GOOGLE - 58 KB.Download Currenc圜onverter_VS2008_GOOGLE (no EXE) - 52.9 KB.Download Currenc圜onverter_VS2008_YAHOO - 58.2 KB.Download Currenc圜onverter_VS2008_YAHOO (no EXE) - 53.2 KB.Download Currenc圜onverter_VS2010_GOOGLE - 62 KB.Download Currenc圜onverter_VS2010_GOOGLE (no EXE) - 56.8 KB.Download Currenc圜onverter_VS2010_YAHOO - 61.1 KB.Download Currenc圜onverter_VS2010_YAHOO (no EXE) - 55.9 KB.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |