Conversion of Decimal to Binary in C#

Posted on Updated on

dwdwdConversion of Decimal to Binary in C#

In interviews, there are some programming questions which you will find most of the places like Write a program to reverse the string or Write a program to check string are palindrome or not etc..

In this post, I have a picked a question from that type of programming questions i.e.

Write a program for converting the decimal value to binary value?

Below is the simple method for converting a decimal value into binary value :

Code Snippet
/// Method for converting Decimal to Binary

///integer value ///
static string DecimalToBinary(int _value)
string strBinary = string.Empty;
while (_value >= 1)
strBinary = (_value % 2).ToString() + strBinary;
_value = _value / 2;
return strBinary;


For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.
Helpline: 9814666333, 8699444666

Please fill the form and we shall contact you soon.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s