I'm doing an encryption program, starting by inverting the string with the following code:
namespace APS
{
class Program
{
public static void Main(string[] args)
{
string frase;
Console.WriteLine("Digite uma frase: ");
frase = Console.ReadLine();
frase = frase.ToLower();
frase = frase.Replace(" ","0");
var chars = frase.ToCharArray();
Console.WriteLine("Original string: {0}", frase);
Console.WriteLine("Character array: ");
for (int i = frase.Length - 1; i > -1; i--)
Console.Write(chars[i]);
}
}
}
It works and the string is inverted. But when I'm going to save chars[i]
to a variable, ie save all inverted string to an error variable, it looks like this:
using System;
namespace APS
{
class Program
{
public static void Main(string[] args)
{
string frase;
Console.WriteLine("Digite uma frase: ");
frase = Console.ReadLine();
frase = frase.ToLower();
frase = frase.Replace(" ","0");
var chars = frase.ToCharArray();
Console.WriteLine("Original string: {0}", frase);
Console.WriteLine("Character array: ");
for (int i = frase.Length - 1; i > -1; i--)
VAR EXEMPLO = chars[i];
//QUAL A FORMA CERTA DE SALVER TODA ESSA SEQUÊNCIA DE CARACTERES?
}
}
}
How do I save and use out of repeat loop for?