public static string titleNationality(string val) { string name = ""; var nameToNationality = CountryDictionary.listOfNationalitie(); if (val != "" || val != "") { //Item Value in dictiona name = nameToNationality.FirstOrDefault(x => x.Value == val).Key; } return(name); }
void guestNationalityDetailsPicker(string nationlity) { Nationality.Items.Clear(); var nameToNationalityList = CountryDictionary.listOfNationalitie(); foreach (string NationalityName in nameToNationalityList.Keys) { Nationality.Items.Add(NationalityName); } if (nationlity != "" || nationlity != "") { //Item value in dictionary string name = nameToNationalityList.FirstOrDefault(x => x.Value == nationlity).Value; //Index of item value in dictionary int index = nameToNationalityList.Values.ToList().IndexOf(name); //Set picker selecteditem index Nationality.SelectedIndex = index; //Set Identification Method to Update guest guestNationality = nationlity; } Nationality.SelectedIndexChanged += (sender, args) => { if (Nationality.SelectedIndex == -1) { guestNationality = nationlity; } else { string nationalityName = Nationality.Items[Nationality.SelectedIndex]; guestNationality = nameToNationalityList[nationalityName]; } }; }