{ 1, 2 }, { 11, 12 }, { 21, 22 }, { 31, 32 }, { 41, 42 }, { 51, 52 } }; int item = Find(matrix, (val) => val == 42); // ref var item = ref Find(matrix, (val) => val == 42); Console.WriteLine(item); item = 24; Console.WriteLine(matrix[4, 1]); } public static ref int Find(int[,] matrix, Func<int, bool> predicate) { for (int i = 0; i < matrix.GetLength(0); i++) for (int j = 0; j < matrix.GetLength(1); j++) if (predicate(matrix[i, j])) return ref matrix[i, j]; throw new InvalidOperationException("Not found"); } 7. ref locals and ref returns