0
In an attempt to debug the code for errors, I often need to enter the requested data, but it is not always possible to reach the end of the program because the execution of the debug via "F10" or "F11" (if you can tell the difference) lock making it impossible to read the next data.
I don’t know why this is happening, and I haven’t found anything about it either. If you can help me with that I’d be grateful.
Here’s a screenshot of the running problem:
using System;
namespace SomaMedia
{
class Program
{
static void Main()
{
string nome_candidato = " ";
int qt_eleitores = 0, qt_brancos = 0, qt_indecisos = 0, qt_intencoes;
int cont = 0, maior = 0, menor = 0;
double percentual_intencoes = 0, percentual_indecisos = 0, percentual_brancos = 0;
int? cod_candidato = null;
while (cod_candidato != 0)
{
Console.Write("QUANTIDADE DE ELEITORES: ");
qt_eleitores = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.Write("CÓDIGO DO CANDIDATO: ");
cod_candidato = int.Parse(Console.ReadLine());
Console.WriteLine();
if (cod_candidato == 0)
{
break;
}
Console.Write("NOME DO CANDIDATO: ");
nome_candidato = Console.ReadLine();
Console.WriteLine();
Console.Write("INTENÇÕES DE VOTO: ");
qt_intencoes = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.Write("VOTOS EM BRANCO: ");
qt_brancos = int.Parse(Console.ReadLine());
Console.WriteLine();
Console.Write("VOTOS INDECISOS: ");
qt_indecisos = int.Parse(Console.ReadLine());
Console.WriteLine();
if (cont == 0)
{
maior = qt_intencoes;
menor = qt_intencoes;
}
if (qt_intencoes > maior)
{
maior = qt_intencoes;
}
if (qt_intencoes < menor)
{
menor = qt_intencoes;
}
percentual_intencoes = ((qt_intencoes / qt_eleitores) * 100);
percentual_brancos = ((qt_brancos / qt_eleitores) * 100);
percentual_indecisos = ((qt_indecisos / qt_eleitores) * 100);
Console.WriteLine($"{percentual_intencoes}% - {nome_candidato}");
}
Console.WriteLine($"{percentual_brancos}% - VOTOS EM BRANCO");
Console.WriteLine($"{percentual_indecisos}% - VOTOS INDECISOS");
}
}
}
Dear Ramon, could you post your code for us to analyze? Thank you. By your image I can see that the process is stopped at a breakpoint.
– Pedro Paulo
Ramon, that "via "F10" or "F11" (if you can tell the difference) hangs making it impossible to read the next data." was not clear to me, can explain better? About the F10 and F11, if it is in a method call (for example
var x = ObterValor();
and use F11, Debugger will enter the "Get value" method if using F10, does not enter the method, just executes and goes to the next line.– Ricardo Pontual
Paulo, as requested, follows the code. But this happens with any code I try to debug.
– Ramon Almeida
Ricardo, next: There was more data to read, right? But after I type what was requested the console is not closed to continue the execution, forcing me to quit by pressing "x" and run the code again.. Sometimes it goes, sometimes it doesn’t. ?
– Ramon Almeida
@Ramonalmeida Do you press the key in Visual Studio or console? Did F5 as well?
– Maniero
@Maniero Worked right here! I was hoping that when I input, the screen would be closed as at the beginning so I could continue with debugging. But just click on Visual Studio and press the F10 that remains normal. Thanks!
– Ramon Almeida