Xamarin Ivalueconverter compare if string is equal a item field string of list

Viewed 50

I really need help this, I have been trying to converter a string value base on this string is equal to another string inside a list.... what I need is to compare if the text field is equal to another text field that is inside a list or database table that is given in the json response above

  public  class IvalueConvertCiudad : IValueConverter
   {

   
    public object Convert(object value, Type targetType, object parameter, CultureInfo 
    culture)
    {
        string cityconverter = value as string;



        foreach (var item in companyListA)
        {
            if (cityconverter == companyListA.NameString)
            {
                string newcityconverter = companyListA.NameString;
                return newcityconverter;

            }
          
        }
       
        return cityconverter;
    }
    public object ConvertBack(object value, Type targetType, object parameter, 
     CultureInfo culture)
    {
        throw new NotImplementedException();
    }

  
   }

  public async void RetornaCiudad()
     {
        var httpClientCD = new HttpClient();
        var resultJsonCD = await httpClientCD.GetStringAsync("URLSTRING");

        var ciudadList = JsonConvert.DeserializeObject<CiudadApi[]>(resultJsonCD);

        var companyListA = ciudadList.ToList();

    }
0 Answers
Related