1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-22 16:43:46 +01:00
CodeWars/8kyu/a_needle_in_the_haystack/solution.cs

16 lines
344 B
C#
Raw Normal View History

using System;
public class Kata {
public static string FindNeedle(object[] haystack) {
var index = 0;
foreach (var o in haystack) {
//if (o is string s && s == "needle") break;
if (o == null);
else if (o.ToString() == "needle") break;
index++;
}
return $"found the needle at position {index}";
}
}