计算器textBox转换为十六进制c#

时间:2015-09-23 15:51:26

标签: string textbox hex decimal calculator

我尝试了两个选项,但都失败并显示十进制结果

private void buttonHex_Click (object sender, EventArgs e) 
        {
            int hex = Convert.ToInt32(textBox1.Text);
            textBox1.Text = hex.ToString("X");
        }

 private void buttonHex_Click (object sender, EventArgs e) 
        {
            double hex = Convert.ToDouble(textBox1.Text);
            long l = (long)hex;
            textBox1.Text = "h " + Convert.ToString(l, 16);
        }

第二个选项适用于二进制,但不想转换为十六进制?!请帮忙

0 个答案:

没有答案