CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Location
    Vadodara, Gujarat, India
    Posts
    52

    Question How to print Binary digit

    Dear friends,

    I am coding in Visual C# windows application. I like to set a Label Text property with given integer's binary.

    eg. I have 1 Label, 1 TextBox and 1 Button when i type 4 in textbox and click on button i want to set label text property with number four's binary that is 0000 0100.

    Kindly tell me how i can print Binary on Form.

  2. #2
    Join Date
    Mar 2008
    Location
    Atlanta, GA
    Posts
    49

    Re: How to print Binary digit

    Quick google search revealed this:

    Code:
    int i = 100;
    string str = Convert.ToString(i, base); //base = 2, 8,10 or 16
    You'll obviously want to use base 2 for binary.

  3. #3
    Join Date
    Apr 2001
    Location
    Vadodara, Gujarat, India
    Posts
    52

    Re: How to print Binary digit

    Thank you very much dear it works nice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured