I have a function here that gets the data from binance api but the problem is, it gets all the trading pairs. I only want to show the ones that ends with USDT in my picker. How do i do that?
public class Crypto
{
public string symbol { get; set; }
public string price { get; set; }
}
private async void GetSymbol()
{
HttpClient client = new HttpClient();
var response = await client.GetStringAsync("https://api.binance.com/api/v3/ticker/price");
var cryptoconverted = JsonConvert.DeserializeObject<List<Crypto>>(response);
var sorted = cryptoconverted.OrderBy(x => x.symbol).ToList();
pairPicker.ItemsSource = sorted;
}
You can use EndsWith() as a condition inside of Linq Where() method:
var sorted = cryptoconverted.OrderBy(x => x.symbol).Where(x => x.symbol.EndsWith("USDT")).ToList();