using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ExToD
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//二进制转换为八进制
private void button1_Click(object sender, EventArgs e)
{
try
{ //把二进数转换为十进制数
int intTen = Convert.ToInt32(textBox1.Text.Trim(), 2);
//把十进制数转换为八进制数
textBox2.Text = Convert.ToString(intTen, 8);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
//二进制转换为十六进制
private void button2_Click(object sender, EventArgs e)
{
//把二进数转换为十进制数
int intTen = Convert.ToInt32(textBox1.Text.Trim(), 2);
//把十进制数转换为八进制数
textBox2.Text = Convert.ToString(intTen, 16);
}
}
}