Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Rate
- {
- public string no { get; set; }
- public string effectiveDate { get; set; }
- public string mid { get; set; }
- }
- public class NBPapi
- {
- public string table { get; set; }
- public string currency { get; set; }
- public string code { get; set; }
- public List<Rate> rates { get; set; }
- }
- public static float wylicz(string kurs)
- {
- WebRequest request = HttpWebRequest.Create(
- "http://api.nbp.pl/api/exchangerates/rates/A/" + kurs + "/?format=json&fbclid=IwAR1I1KkXoCFuiJ3HCIOJ4uPqVH_WQLimmHQN0ZOjcHihLLpVm0bhXyoobjA");
- WebResponse response = request.GetResponse();
- StreamReader reader = new StreamReader(response.GetResponseStream());
- string jsonik = reader.ReadToEnd();
- NBPapi nbpapi = Newtonsoft.Json.JsonConvert.DeserializeObject<NBPapi>(jsonik);
- string usdCurr = nbpapi.rates.ElementAt(2).ToString();
- return float.Parse(usdCurr);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement