0

Help me please..
I can't make this code in window form application..

using System;

namespace _01.Decimal_to_Binary
{
    class DecimalToBinary
    {
        static void Main(string[] args)
        {
            Console.Write("Decimal: ");
            int decimalNumber = int.Parse(Console.ReadLine());

            int remainder;
            string result = string.Empty;
            while (decimalNumber > 0)
            {
                remainder = decimalNumber % 2;
                decimalNumber /= 2;
                result = remainder.ToString() + result;
            }
            Console.WriteLine("Binary:  {0}",result);
        }
    }
}

please help me..
thanks

5
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by Mitja Bonca
1

Create your form, put a textbox, a label and a button on it. Put the conversion code inside the 'click' event of the button. Use the value from the textbox rather than from ReadLine(). Put the result in the label.

0

As momerath stated, you need differenrt approach then in Console. You need some controls, where you will insert your data (exchange Textbox control for Console.ReadLine() method).
Then insert a Label, where yo will show results (exchnage for Console.WriteLine() method).
And use same method as you are using now for do the calculation.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.