Skip to content

Instantly share code, notes, and snippets.

@minons1
Created March 31, 2021 16:47
Show Gist options
  • Save minons1/1cdc4095f3b3556dae6776584dbb034d to your computer and use it in GitHub Desktop.
Save minons1/1cdc4095f3b3556dae6776584dbb034d to your computer and use it in GitHub Desktop.
Dynamic Currency Converter using API in .NET Framework C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Http;
using Newtonsoft.Json.Linq;
namespace Currency_Converter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
boxKanan.DropDownStyle = ComboBoxStyle.DropDownList;
boxKiri.DropDownStyle = ComboBoxStyle.DropDownList;
}
private async void con_button(object sender, EventArgs e)
{
var convert = $"{boxKiri.Text}_{boxKanan.Text}";
var key = [YOUR_API_KEY];
var url = $"https://free.currconv.com/api/v7/convert?q={convert}&compact=ultra&apiKey={key}";
using var client = new HttpClient();
var content = await client.GetStringAsync(url);
var CurrencyObject = JObject.Parse(content);
textKanan.Text = (Double.Parse(CurrencyObject[convert].ToString()) * Double.Parse(textKiri.Text)).ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment