-3
I am learning C# (Good at the beginning of learning) and I saw that anything that the user inserts by "Console.Readline();" is considered as a string automatically by Visual Studio, but how do I convert the value to another type of variable? The "Name" part works normally because it is a variable of type "string", but the "Age" part I can’t do the attribution of it because it is "int", what would I have to add or change to work? (do not call the last readline, it is only for the program does not close automatic)
string nome;
int idade;
Console.WriteLine("Insira seu nome: ");
nome = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("insira sua idade: ");
idade = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("seu nome é:"+ nome);
Console.WriteLine("sua idade é:"+ idade);
Console.ReadLine();
é considerada como uma string automaticamente pelo Visual Studio
no, see https://answall.com/q/101691/101. And the answer given only works in practice if the person enters the correct value, gives error in real application. It is good the people who come to Sopt to be attentive because today a lot of the answers given are teaching to do wrong, it was the time that the answers were almost always good.– Maniero
@Maniero feel free to post your reply.
– FourZeroFive
This has already been answered a huge number of times. Read: https://pt.meta.stackoverflow.com/q/8573/101
– Maniero