step 1: Syntax While Loop
step 2: Logic Binary Number - protected void Button1_Click(object sender, EventArgs e)
- {
- int intNo = Convert.ToInt32(txtNo.Text.Trim());
- int intBinary;
- string strBinary = "";
- while (intNo != 0)
- {
- intBinary = intNo % 2;
- intNo = intNo / 2;
- strBinary = intBinary + strBinary;
- }
-
- lblBinaryNo.Text = strBinary;
- }
You can implement while loop concept and modulo and division operation easily.