1
I would like to know a way in which the output of my project, appear in a textarea in Windowsforms. I need this because my system is a binary number converter, and I want you to print out the step-by-step calculation on the screen. If there is another way, I accept suggestions!
Method example:
public int ConverterDeBinarioParaDecimal(String numeroBinario)
{
double resultado = 0;
int qtdDigitos = numeroBinario.Length;
Console.WriteLine("xxx = {0}", qtdDigitos);
for (int cont = 0; cont < qtdDigitos; cont++)
{
if (numeroBinario[cont] == '1')
{
resultado = resultado + Math.Pow(2, qtdDigitos - (cont + 1));
}
}
int resultadoConversao = Convert.ToInt32(resultado);
return resultadoConversao;
}
What’s wrong with replacing
Console.WriteLine
forMessageBox.Show
orTextBox1.Text
? Since it is windows Forms it makes sense to use the appropriate things in this context.Console
, as its name implies, it is for console mode applications.– Isac