I need to divide the characters of a sentence and eliminate their spaces and place them in a matrix, the order of the matrix will depend on the number of characters in the sentence, eh made this code but the error I have is that it shows me the last letter of the sentence in all positions of the matrix:
char[,] A;
int orden;
int x;
string cadena = txtfrase.Text.Trim();
orden = int.Parse(cadena.Length.ToString());
if (orden % 2 == 0)
{
x = orden;
if (orden >= 0)
{
int i;
for (i = 0; i < 20; i++)
x = (((x * x) + orden) / (2 * x));
}
A = new char[x, x];
for (int i = 0; i < A.GetLength(0); i++)
{
for (int j = 0; j < A.GetLength(1); j++)
{
for (int l = 0; l < cadena.Length; l++)
A[i, j] = cadena[l];
}
}