mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
15 lines
344 B
C#
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}";
|
|
}
|
|
}
|