diff --git a/num-converter/WebForm1.aspx.cs b/num-converter/WebForm1.aspx.cs index 4e06ed8..f08bcd6 100644 --- a/num-converter/WebForm1.aspx.cs +++ b/num-converter/WebForm1.aspx.cs @@ -16,7 +16,31 @@ namespace num_converter protected void btnConvert_Click(object sender, EventArgs e) { + String Result = string.Empty; + int Remainder; + int DecimalNum; + int BinaryNum; + int OctalNum; + int Base1 = 1; + + if (ddlSourcePosNum.SelectedIndex == 1 && ddlTargetPosNum.SelectedIndex == 2) + { + DecimalNum = Convert.ToInt32(txtInput.Text); + while (DecimalNum > 0) + { + Remainder = DecimalNum % 2; + DecimalNum /= 2; + Result = Remainder.ToString() + Result; + } + lblResult.Text = Result; + } + if (ddlSourcePosNum.SelectedIndex == 2 && ddlTargetPosNum.SelectedIndex == 1) + { + BinaryNum = Convert.ToInt32(txtInput.Text, 2); + Result = BinaryNum.ToString(); + lblResult.Text = Result; + } } protected void btnClear_Click(object sender, EventArgs e)