Guest User

Untitled

a guest
Mar 22nd, 2021
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Newtonsoft.Json;
  7.  
  8. namespace Currency_Conversion_App {
  9.     class CurrencyList {
  10.         public Dictionary<string, CurrencyData> results;
  11.  
  12.         public CurrencyData getCurrencyByID(string id) {
  13.             return results[id];
  14.         }
  15.  
  16.         public CurrencyData GetCurrencyByIndex(int index) {
  17.             return results.ElementAt(index).Value;
  18.         }
  19.  
  20.         public CurrencyData[] ToArray() {
  21.             return results.Values.ToArray();
  22.         }
  23.  
  24.         public static CurrencyList Deserialize(string data) {
  25.             return JsonConvert.DeserializeObject<CurrencyList>(data);
  26.         }
  27.  
  28.     }
  29.  
  30.     class CurrencyData {
  31.         public string currencyName;
  32.         public string currencySymbol;
  33.         public string id;
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment