static void Main(string[] args)
Console.Write("Input the number of rows and collumns: ");
String[] input = Console.ReadLine().Split(' ');
while (!int.TryParse(input[0], out rows) || !int.TryParse(input[1], out cols))
Console.Write("Invalid Input, please re-enter: ");
input = Console.ReadLine().Split(' ');
int[,] matrix = new int[rows, cols];
for(int r = 0; r < rows; r++)
for(int c = 0; c < cols; c++)
Console.Write($"Enter Element [{r}, {c}]: ");
while (!int.TryParse(Console.ReadLine(), out val))
Console.Write("Invalid Input, please re-enter: ");
Console.WriteLine("Matrix:");
int[,] transpose = new int[cols, rows];
for (int r = 0; r < rows; r++)
for (int c = 0; c < cols; c++)
transpose[c, r] = matrix[r, c];
Console.WriteLine("Transposed Matrix:");
public static void print2DArray(int[,] matrix)
for (int r = 0; r < matrix.GetLength(0); r++)
for (int c = 0; c < matrix.GetLength(1); c++)
Console.Write(matrix[r, c] + " ");