How to print the bits of an integer in 8 bit format with C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        int num = 17;
        
        Console.WriteLine(Convert.ToString(num, 2).PadLeft(8, '0'));
    }
}




/*
run:

0000000000010001

*/

 



answered Jan 9, 2023 by avibootz

Related questions

1 answer 122 views
1 answer 109 views
1 answer 99 views
1 answer 103 views
1 answer 108 views
...