/// <summary>
 /// On press button, tryes to convert a Decimal to a Binary number, then shows it in the txtResultadoBin.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDecToBin_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(txtDecimal.Text) && Double.TryParse(txtDecimal.Text, out Double value))
     {
         NumeroDecimal decimalNumber = (NumeroDecimal)value;
         txtResultadoBin.Text = ((NumeroBinario)decimalNumber).GetBinaryNumber();
     }
     else
     {
         MessageBox.Show("Error while trying to convert the Decimal to Binary.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Beispiel #2
0
        private void btnDecToBin_Click(object sender, EventArgs e)
        {
            bool validar = double.TryParse(textBox2.Text, out double nro);

            if (validar == true)
            {
                // SI TODO ESTA OK CREAMOS EL OBJETO Y EMPEZAMOS LA CONVERSION
                NumeroDecimal nroDecimal = new NumeroDecimal(nro);
                txtResultadoBin.Text = (string)nroDecimal;
            }
            else
            {
                // SI EL VALOR INGRESADO NO ES UN NRO GENERAMOS  UN ERROR
                MessageBox.Show("Ingrese un número!", "Error Detectado", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }