using System;
using System.Collections.Generic;
using System.Linq;
class MainClass
{
static void Main()
{
//Console.WriteLine("Hello World!");
string[] nemo = new string[] { "nemo1", "nimo" };
Console.WriteLine(FindingNemoImproved(nemo, "nemo1"));
}
static string FindingNemoImproved(IEnumerable<string> enumerable, string toFind)
{
return enumerable
.Where(str => str == toFind)
.Aggregate(
"Better luck next time", (defaultmsg, nemo) => "Found " + nemo
);
}
static string FindingNemo(string[] inputArray, string toFind)
{
string result = null;
foreach (var str in inputArray)
{
if(str != toFind)
{
result = "Better luck next time!";
}
else
{
result = "Found " + toFind;
break;
}
}
return result;
}
}