Get USD to INR exchange rate dynamically in C#?

前端 未结 3 473
我在风中等你
我在风中等你 2021-01-07 08:03

\"enter

I\'m developing a Windows application to convert USD to INR. I know how to con

相关标签:
3条回答
  • 2021-01-07 08:24

    Here is the code piece: Add System.IO and System.Net and System.Xml

    WebRequest webrequest =WebRequest.Create("http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=INR");
            HttpWebResponse response = (HttpWebResponse)webrequest.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string responseFromServer = reader.ReadToEnd();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(responseFromServer);
            string value = doc.InnerText;
            MessageBox.Show(value);
            reader.Close();
            dataStream.Close();
            response.Close();
    
    0 讨论(0)
  • 2021-01-07 08:28

    Conversion Rate is the right method to call. You can add a service method to your project. You may have to point it to the WSDL file. Make one call to get the base rate and then calculate the other rate by using 1/result of the first call.

    0 讨论(0)
  • 2021-01-07 08:34

    If you don't want to add the service reference, you can also just request the page: http://www.webservicex.net/currencyconvertor.asmx/ConversionRate?FromCurrency=USD&ToCurrency=INR

    0 讨论(0)
提交回复
热议问题