DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links