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
You can do it by this.
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