Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns the hexadecimal representation of the octal number.
 /// </summary>
 public Hexadecimal GetHexadecimal()
 {
     NSConvert.Decimal @decimal = GetDecimal();
     return(new Hexadecimal(@decimal.GetHexadecimal().ToString()));
 }