|
新手写的进制转换器(写的很笨)(8) else b=b+((int)ten[i]-48)*c; c=1; } textBox5.Text=b.ToString("x8"); } //由十进制转二进制 void T_Tw() { int b=0; string ten; int c=1; ten=textBox3.Text; for(int i=0;i<ten.Length;i++) { for(int j=ten.Length-i-1;j>0;j--) { c=c*10; } b=b+((int)ten[i]-48)*c; c=1; } textBox4.Text=Convert.ToString(b,2); } //二进制转十进制 void Tw_T() { string two; two=textBox4.Text; int p=Convert.ToInt32(two,2); textBox3.Text=p.ToString(); } //二进制转十六进制 void Tw_S() { string two; two=textBox4.Text; int s=Convert.ToInt32(two,2); textBox5.Text=s.ToString("x8"); } private void timer1_Tick(object sender, System.EventArgs e) { DateTimeToString(); } } }
|