using System; public class Test { // Original string array public static readonly string[,] first = { {"2", " ", " ", " ", "1"}, {"2", " ", "4", "3", " "}, {" ", "2", " ", "1", " "}, {" ", "1", " ", "3", " "}, {"1", " ", " ", " ", " "} }; public static void Main() { // Convert int[,] second = new int[first.GetLength(0), first.GetLength(1)]; for (int j = 0; j < first.GetLength(0); j++) { for (int i = 0; i < first.GetLength(1); i++) { int number; bool ok = int.TryParse(first[j, i], out number); if (ok) { second[j, i] = number; } else { second[j, i] = 0; } } } // Print in console for (int i = 0; i < second.GetLength(0); i++) { for (int j = 0; j < second.GetLength(1); j++) Console.Write(second[i, j] + "\t"); Console.WriteLine(); } Console.ReadLine(); } }