这里所说的数值类型包括 byte, short, int, long, fload, double 等,根据这个排列顺序,各种类型的值依次可以向后自动进行转换。举个例来说,把一个 short 型的数据赋值给一个 int 型的变量,short 值会自动行转换成 int 型值,再赋给 int 型变量。如下例:
private void TestBasic() { byte a = 1; short b = a; int c = b; long d = c; float e = d; double f = e; this.textBox1.Text = ; this.textBox1.AppendText(byte a = + a.ToString() + \n); this.textBox1.AppendText(short b = + b.ToString() + \n); this.textBox1.AppendText(int c = + c.ToString() + \n); this.textBox1.AppendText(long d = + d.ToString() + \n); this.textBox1.AppendText(float e = + e.ToString() + \n); this.textBox1.AppendText(double f = + f.ToString() + \n); }