How to deploy matrix(C#)?

There is a line with any nonsense. This line needs to turn into an array... I did it like this(I'm new to C#, I do not know all the peculiarities of this language).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Rextester
{
 public class Program
{
 public static void Main(string[] args)
{
 var str = "the ENEMY WILL be DEFEATED";
 str = str.Replace(" ", string.Empty);//delete spaces

 char[] array = str.ToCharArray();//string ----> array

 for (int i = 0; i < array.Length; i += 3)//need to flip the matrix...
{
 Console.Write(array[i] + " ");
 for (int j = i + 1; j < i + 3; j++)
{
 Console.Write(array[j] + " ");
}
 Console.WriteLine(" ");
}
 Console.WriteLine(" \n");
}
}
}

This array becomes a matrix, and in case it is necessary to rotate the matrix, so how to do it?
For clarity, give an example string of code....
The initial matrix:
IN R A
G B Y
D E T
R AND S
B I T

Expectation:
IN D E R B
R B E A AND
AND T H A T
March 20th 20 at 11:19
1 answer
March 20th 20 at 11:21
Solution
The fact that You brought an array as a matrix, does not mean that You created the matrix. In the usual case the matrix is initialized with a double loop, where the external considers the rows, and the inner column. At the corner, just change places - considers external columns and internal rows.
static void Main(string[] args)
{
 var str = "the ENEMY WILL be DEFEATED";
 str = str.Replace(" ", string.Empty);
 char[] array = str.ToCharArray();

 var columnCount = 5;
 var rowCount = array.Length / columnCount;
 if (rowCount * columnCount < array.Length)
{
rowCount++;
}

 // Creating inverted matrix
 var invertedArray = new char[rowCount, columnCount];
 var counter = 0;
 for (var i = 0; i < columnCount; i++)
{
 for (var j = 0; j < rowCount; j++)
{
 invertedArray[j, i] = array[counter++];
}
}

 // Print matrix to the screen in a standard way
 for (var j = 0; j < rowCount; j++)
{
 for (var i = 0; i < columnCount; i++)
{
 Console.Write(invertedArray[j, i]);
}
Console.WriteLine();
}

Console.ReadKey();
}

Find more questions by tags C#