コード例 #1
0
        /// <summary>
        /// Returns the binary representation of the octal number.
        /// </summary>
        public Binary GetBinary()
        {
            string binary = "";

            for (int i = 0; i < octal.Length; i++)
            {
                NSConvert.Decimal @decimal = new Decimal(octal[i] - '0');
                binary += @decimal.GetBinary();
            }
            return(new Binary(binary));
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Ahmed-Hafez/MSP_Tasks
 private void decimalBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(decimalTxt.Text) || string.IsNullOrWhiteSpace(decimalTxt.Text))
         {
             MessageBox.Show("Enter decimal number to convert.", "Format Error",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
             reset();
             return;
         }
         NSConvert.Decimal @decimal = new Decimal(double.Parse(decimalTxt.Text));
         binaryTxt.Text      = @decimal.GetBinary().ToString();
         octalTxt.Text       = @decimal.GetOctal().ToString();
         hexadecimalTxt.Text = @decimal.GetHexadecimal().ToString();
     }
     catch
     {
         MessageBox.Show("Invalid decimal format", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         reset();
     }
 }