47. 随堂练习 1. 下面声明了一些数值类型的变量
short s=10; int i=5; uint ui=50; long l=1000; double d=45.3;decimal m = 154;
2. 试着分析下列哪些类型转换是正确的:
s = ui; i = ui; s = l; l = s; m = d; d = m; l = d; m = i;
48. 随堂练习 (续)3. 试着写出以下这段程序的运行结果:
using System;
using System.Collections.Generic;
using System.Text;
namespace convert
{
enum Color{ Red,Yellow,Blue,Green,Purple,Black,White
};
class Program
{
static void Main(string[] args)
{
Color [] color_arr=new Color [3];
int[] int_arr = new int[]{1,2,3};
color_arr[0] = (Color)int_arr[0];
color_arr[1] = (Color)int_arr[1];
color_arr[2] = (Color)int_arr[2];
Console.WriteLine("The value of color_arr[0] is :{0}", color_arr[0]);
Console.WriteLine("The value of color_arr[1] is :{0}", color_arr[1]);
Console.WriteLine("The value of color_arr[2] is :{0}", color_arr[2]);
}
}
}