1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-09 11:09:07 +01:00
CodeWars/8kyu/a_needle_in_the_haystack/solution.cs
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

15 lines
344 B
C#

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}";
}
}