Convert Integer to 2-base, 8-base string?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Convert Integer to 2-base, 8-base string?

  1. #1
    Tom Shelton Guest

    Re: Convert Integer to 2-base, 8-base string?


    "David Chu" <chud@hotmail.com> wrote in message
    news:3ea56e15$1@tnews.web.devx.com...
    >
    > By using the following statement, I can convert an integer to a hexdecimal
    > string:
    >
    > string sMyHex = string.format("{0:x}", 12345);
    >
    > I could not find a similar way to convert an integer to a 2 or 8 based

    string.
    > For example,
    >
    > 2 -> "10" (2-based)
    > 8 -> "10" (8-based)
    >
    > Is there any function to do the conversion?
    >
    > Thanks for any help!
    >
    > D. Chu


    Console.WriteLine(Convert.ToString(2, 2));
    Console.WriteLine(Convert.ToString(8, 2));

    HTH,
    Tom Shelton



  2. #2
    David Chu Guest

    Convert Integer to 2-base, 8-base string?


    By using the following statement, I can convert an integer to a hexdecimal
    string:

    string sMyHex = string.format("{0:x}", 12345);

    I could not find a similar way to convert an integer to a 2 or 8 based string.
    For example,

    2 -> "10" (2-based)
    8 -> "10" (8-based)

    Is there any function to do the conversion?

    Thanks for any help!

    D. Chu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center