Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7857723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:07:38+00:00 2026-06-02T21:07:38+00:00

I have tried this way to get the binary representation in C# int i

  • 0

I have tried this way to get the binary representation in C#

int i = 1;
string binary = Convert.ToString(i, 2);

it returns a single char string “1”

i need a n digit string suppose the number is 8 n i want a 5 digit binary representation,

i need it to be “01000”

number of digits (n) is the input.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:07:40+00:00Added an answer on June 2, 2026 at 9:07 pm

    You can do it by this.

    string str = Convert.ToString(8, 2).PadLeft(5, '0');
    

    PadLeft is used to put the 0 on left of expression here we have given 5 is totol width of number. and second parament is character to put on left when number is less then 5 characters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this array, and I've tried to return it like the same way
I have tried this code but no data is lost from the listview when
I have tried this url to insert uitextfield in custom cell but what i
I have tried this: <div style=width:52px;overflow:hidden;> <fb:like layout=button_count></fb:like> <div id=fb-root></div> <script> window.fbAsyncInit = function()
I have tried this but it does not work (even if I specify .wav
i have tried this: <?php $fileip = fopen(test.txt,r); ?> this should have opened the
i have tried this code to redirect a php page.but it s not working
I have tried this but it doesn't work: tell application Preview set myfile to
I have tried this example http://www.bennadel.com/blog/1056-ColdFusion-CFPOP-My-First-Look.htm , but it retrieve emails from POP server.
I have tried this a few different ways and it always seems to fail.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.