在窗体中新建一个按钮,并在它的单击事件中调用该 TestAlias() 函数,我们将看到运行结果如下:
byte -> System.Byte
char -> System.Char
short -> System.Int16
int -> System.Int32
long -> System.Int64
uint -> System.UInt32
bool -> System.Boolean
这足以说明各别名对应的类!
2. 数值类型之间的相互转换
这里所说的数值类型包括 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 = "
评论加载中…
![]() |