static void Main(string[] args)
{
string[] arr = new string[5] { "tests", "Google", "good","yes","grey" };
Console.WriteLine(Array.Find(arr, StartwithG));
Console.WriteLine(Array.FindLast(arr, StartwithG));
string[] arrstartwithg = Array.FindAll(arr, StartwithG);
foreach (string str in arrstartwithg)
{
Console.WriteLine(str);
}
}
static bool StartwithG(string str)
{
if (str.ToLower().StartsWith("g"))
return true;
else return false;
}
No comments:
Post a Comment