-5
I’m doing an encryption program, starting to reverse 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]);
}
}
}
Works and the string is reversed. But when I go to save chars[i]
in a variable, i.e., save all string reversed into 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 loop loop for
?
What is the need to write everything in high box?
– user28595
I recommend you read this link.
– user28595
But is that really how you wrote it? This is a really wrong syntax, you know the syntax of C#?
– Maniero