using System; using System.Collections.Generic; using System.Linq; using System.Globalization; public class Test { private static readonly int[][] matrix = new int[6][]; static Test() { matrix[0] = new int[] { 1, 2, 3, 4, 5, 6 }; matrix[1] = new int[] { 7, 8, 9, 10, 11, 12 }; matrix[2] = new int[] { 13, 14, 15, 16, 17, 18 }; matrix[3] = new int[] { 19, 20, 21, 22, 23, 24 }; matrix[4] = new int[] { 25, 26, 27, 28, 29, 30 }; matrix[5] = new int[] { 31, 32, 33, 34, 35, 36 }; } public static void Main() { var hours = Enumerable.Range(00, 24).Select(i => i.ToString("D2")); int num = 15; var matches = matrix .Select((arr, index) => new { arr, xPos = index + 1 }) .Where(x => x.arr.Contains(num)) .Select(x => new { X = x.xPos, Y = (x.arr.Select((n, i) => new { n, i }) .First(xy => xy.n == num).i) + 1 }); if (matches.Any()) { var firstMatch = matches.First(); int x = firstMatch.X; int y = firstMatch.Y; Console.Write("X:{0} Y:{1}", x,y); } else Console.Write("Value not found in matrix"); } }