我尝试了两个选项,但都失败并显示十进制结果
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);
}
第二个选项适用于二进制,但不想转换为十六进制?!请帮忙