简体   繁体   中英

Xamarin Android: Ilist<Address> does not contain a definition for 'Any'

I'm trying obtain adrress from Location using this steps. I obtain correctly latitude and longitude, but I need specific address too. If exist other tutorial to obtain this.

http://developer.xamarin.com/recipes/android/os_device_resources/gps/get_current_device_location/

void InitializeLocationManager()
{
    _locationManager = (LocationManager)GetSystemService(LocationService);
    Criteria criteriaForLocationService = new Criteria
                                            {
                                                Accuracy = Accuracy.Fine
                                            };
    IList<string> acceptableLocationProviders = _locationManager.GetProviders(criteriaForLocationService, true);

    if (acceptableLocationProviders.Any())
    {
        _locationProvider = acceptableLocationProviders.First();
    }
    else
    {
        _locationProvider = String.Empty;
    }
}

In this code the errors are:

System.Collection.Generic.Ilist does not contain a definition for 'Any'

Add using System.Linq; to the top to the source file. Any() is an extension method to IEnumerable within the System.Linq namespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM