cheesebunz
cheesebunz

Reputation: 570

How do i convert String to currency?

i am using 2 web services:

http://www.webservicex.com/currencyconvertor.asmx?WSDL

http://www.oorsprong.org/websamples.countryinfo/CountryInfoService.wso

One the second webservice i used ListOfCurrenciesByCode method and got the isoCode of currency and listed it in a dropdownlist1.DataTextField = "sISOCode"; and i get all the countries' ISOCODE.

Now i want to convert values using first link webservice using webmethod ConversionRate. How do i convert ?the ConversionRate method only seems to want me to input

 ConversionRate(Currency fromcurrency, Currency tocurrency).

How do i do that?

Upvotes: 0

Views: 7588

Answers (2)

Kon
Kon

Reputation: 27441

String.Format("{0:C}", value);

Documentation: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

Upvotes: 4

SwDevMan81
SwDevMan81

Reputation: 49978

Taken from here

public string getConversionRate(string CurrencyFrom, string CurrencyTo)
{
   CurrencyConvertor curConvertor = new CurrencyConvertor();
   double rate = curConvertor.ConversionRate(
      (Currency)Enum.Parse(typeof(Currency), CurrencyFrom),
      (Currency)Enum.Parse(typeof(Currency), CurrencyTo));
   return rate.ToString();
}

Upvotes: 1

Related Questions