Accessing the array

hello, i have this code, just an array and method, i want to take an determinate value from the array and use like a true valor.
But the code is wrong…and i dont understand why… THANK YOU !!!

THis is the Error ( Not all code paths return a value (CS0161) (Assembly-CSharp) )

public class BusquedaArray : MonoBehaviour {

public string paisesEuropeos = new string{ “España”, “Francia”, “Alemania”, “Italia”, “Inglaterra” };

	bool CheckPais ( ){

	for (int i = 0; i < paisesEuropeos.Length; i++) {

		if (paisesEuropeos  *== "Chile") {*
  •   		return true;*
    
  •   	} else {*
    
  •   		return false;*
    
  •   	}*
    
  •   }*
    
  • }*
    }

You need to return true or false outside the loop as well.

        private string[] paisesEuropeos = { "España", "Francia", "Alemania", "Italia", "Inglaterra" };

        private bool CheckPais()
        {
            foreach (var current in this.paisesEuropeos)
            {
                return current == "Chile";
            }
            return false;
        }

or by using Linq :

 private string[] paisesEuropeos = { "España", "Francia", "Alemania", "Italia", "Inglaterra" };

        private bool CheckPais()
        {
            return this.paisesEuropeos.Select(current => current == "Chile").FirstOrDefault();
        }

wow thanks ! i dont know this way :stuck_out_tongue: let me check what can i do now :slight_smile: